Beispiel #1
0
def getFuTuProperty(param):
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'cn.futu.trader'
    settingData['appActivity'] = '.launch.activity.LaunchActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    closeId = 'cn.futu.trader:id/close_popup_ad_view'
    if isExist(driver, 4, closeId):
        driver.find_element_by_id(closeId).click()
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("今日盈亏")').click()
    sleep(1)
    allPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout[2]/android.widget.TextView'
    allNum = driver.find_element_by_xpath(allPath).text
    availablePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.view.ViewGroup/android.widget.LinearLayout[2]/android.widget.TextView'
    availableNum = driver.find_element_by_xpath(availablePath).text
    param = {
        'method': 0,
        'tableName': 'fuTu0',
        'allNum': allNum,
        'availableNum': availableNum,
    }
    initMysql(param)
    driver.quit()
Beispiel #2
0
def getTigerProperty(param):
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.tigerbrokers.stock'
    settingData['appActivity'] = '.ui.StartupActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    loginTiger(driver)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("交易")').click()
    sleep(2)
    if isExist(driver, 4, 'com.tigerbrokers.stock:id/btn_cancel'):
        driver.find_element_by_id(
            'com.tigerbrokers.stock:id/btn_cancel').click()
        sleep(1)

    allId = 'com.tigerbrokers.stock:id/text_asset_total'
    allNum = str(
        float('%.2f' %
              (float(driver.find_element_by_id(allId).text.replace(',', '')) *
               7.7)))
    availableId = 'com.tigerbrokers.stock:id/text_assets_value_left'
    availableNum = driver.find_element_by_id(availableId).text
    param = {
        'method': 0,
        'tableName': 'tiger0',
        'allNum': allNum,
        'availableNum': availableNum,
    }
    initMysql(param)
    driver.quit()
Beispiel #3
0
def getYouYuProperty(param):
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.ruifusoft.finance.app'
    settingData['appActivity'] = 'com.ruifusoft.ui.SplashActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("我的")').click()
    sleep(1)
    allPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.TextView[3]'
    allNum = driver.find_element_by_xpath(allPath).text
    availablePath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout/android.widget.TextView[2]'
    availableNum = driver.find_element_by_xpath(availablePath).text
    param = {
        'method': 0,
        'tableName': 'youYu0',
        'allNum': allNum,
        'availableNum': availableNum,
    }
    initMysql(param)
    driver.quit()
Beispiel #4
0
def getZunJiaProperty(param):
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.juniorchina.jcstock'
    settingData['appActivity'] = '.SplashActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(5)
    driver.launch_app()
    sleep(5)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("交易")').click()
    sleep(1)
    allPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.TextView'
    allNum = driver.find_element_by_xpath(allPath).text
    availablePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]/android.widget.TextView[1]'
    availableNum = driver.find_element_by_xpath(availablePath).text
    param = {
        'method': 0,
        'tableName': 'zunJia0',
        'allNum': allNum,
        'availableNum': availableNum,
    }
    initMysql(param)
    driver.quit()
Beispiel #5
0
def getfuYuanProperty(param):
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.sunline.android.sunline'
    settingData['appActivity'] = '.DefaultAlias'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    if isExist(driver, 4, 'com.sunline.android.sunline:id/cancel'):
        driver.find_element_by_id(
            'com.sunline.android.sunline:id/cancel').click()
        sleep(1)

    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("交易")').click()
    sleep(2)
    allPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.TextView'
    allNum = driver.find_element_by_xpath(allPath).text
    availablePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.TextView[2]'
    availableNum = numFromStr(driver.find_element_by_xpath(availablePath).text)
    param = {
        'method': 0,
        'tableName': 'fuYuan0',
        'allNum': allNum,
        'availableNum': availableNum,
    }
    initMysql(param)
    driver.quit()
Beispiel #6
0
def recordPrice(driver, param):
    pricePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView'
    maxPricePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[2]/android.widget.TextView[2]'
    maxText = driver.find_element_by_xpath(maxPricePath).text
    if isNumber(maxText):
        nowPrice = float(driver.find_element_by_xpath(pricePath).text[0:5])
        maxPrice = float(driver.find_element_by_xpath(maxPricePath).text)
        minPricePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[5]/android.widget.TextView[2]'
        minPrice = float(driver.find_element_by_xpath(minPricePath).text)
        todayPercentagePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView[2]'
        todayPercentage = float(
            driver.find_element_by_xpath(todayPercentagePath).text[0:4])
        priceInit = param['priceInit']
        percentage = round((nowPrice - priceInit) / priceInit, 2)
        tradeUp = param['tradeUp']
        tradeSum = param['tradeSum']
        tableName = 'code' + param['code']
        ticks = time.time()
        recordTime = int(ticks)
        print(recordTime)
        print(nowPrice)
        print(maxPrice)
        print(minPrice)

        param = {
            'method': 0,
            'tableName': tableName,
            'nowPrice': nowPrice,
            'maxPrice': maxPrice,
            'minPrice': minPrice,
            'percentage': todayPercentage,
            'recordTime': recordTime,
        }
        initMysql(param)
        # if percentage > tradeUp:
        if False:
            tradeParam = {'nowPrice': nowPrice, 'tradeSum': tradeSum}
            tradePrice(driver, tradeParam)
            return False
        else:
            backPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.ImageButton'
            driver.find_element_by_xpath(backPath).click()
            sleep(1)
            return True
def getHuaShengTongProperty(param):
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.huasheng.stock'
    settingData['appActivity'] = 'com.hstong.app.launch.ui.Loading'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(6)
    if isExist(driver, 4, 'com.huasheng.stock:id/button_cancel'):
        driver.find_element_by_id(
            'com.huasheng.stock:id/button_cancel').click()
    if isExist(driver, 4, 'com.huasheng.stock:id/btn_close'):
        driver.find_element_by_id('com.huasheng.stock:id/btn_close').click()
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("交易")').click()
    sleep(1)
    if isExist(driver, 3, 'android.widget.EditText'):
        pwd = getPwd('huaShengTong')['tradePwd']
        driver.find_element_by_class_name('android.widget.EditText').send_keys(
            pwd)
        driver.find_element_by_id('com.huasheng.stock:id/btn_login').click()
        sleep(5)
    allPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.TextView[2]'
    allNum = driver.find_element_by_xpath(allPath).text
    availablePath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.view.ViewGroup/android.widget.LinearLayout[2]/android.widget.TextView[2]'
    availableNum = driver.find_element_by_xpath(availablePath).text
    param = {
        'method': 0,
        'tableName': 'huaShengTong0',
        'allNum': allNum,
        'availableNum': availableNum,
    }
    initMysql(param)
    driver.quit()
    print(allNum)
    print(availableNum)