In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Original articles, welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!
Original link address: "docker practice" python's docker crawler technology-appium+python practice (18)
Last time through appium, the function of recording script, but also can be converted into python,java,js and other languages, this actual combat, from login, to enter a page operation to get information.
Source code: https://github.com/limingios/dockerpython.git
Process code
1. Click to skip the navigation page to go to the login page
two。 Enter your user name and password and click Log in
3. Click "agree" to enter the page, and click "Research"
4. Simulate gestures, move up
Prepare for the installation [postgraduate entrance examination]
two。 Settings-Application-Click "Postgraduate entrance examination Group"-clear data
Start [postgraduate entrance examination]
Start uiautomatorviewer.bat in Direct adb and remember to check out the enhanced version in the download source package.
5. See uiautomatorviewer and Night God Simulator
6.appium start
Write code
#! / usr/bin/env python
-- coding: utf-8-- @ Time: 2019-1-22 20:15@Author: Aries@Site: @ File: yankao.py@Software: PyCharm
# pip3 install Appium-Python-Client
Import time
From appium import webdriver
From selenium.webdriver.support.ui import WebDriverWait
Cap = {
"platformName": "Android"
"platformVersion": "5.1.1"
"deviceName": "127.0.0.1 purl 62001"
"appPackage": "com.tal.kaoyan"
"appActivity": "com.tal.kaoyan.ui.activity.SplashActivity"
"noReset": True
}
Driver = webdriver.Remote ("http://localhost:4723/wd/hub",cap)
Def get_size ():
X = driver.get_window_size () ['width']
Y = driver.get_window_size () ['height']
Return (XBI y)
# Navigation click skip
Try:
# whether to skip
If WebDriverWait (driver,3) .managers (lambda x:x.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.TextView [1]")):
Driver.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.TextView [1]") .click ()
Except:
Pass
Try:
If WebDriverWait (driver,3) .managers (lambda x:x.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.ScrollView [1] / android.widget.LinearLayout [1] / android.widget.EditText [1]")):
Driver.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.ScrollView [1] / android.widget.LinearLayout [1] / android.widget.EditText [1]") .send_keys ("idig8")
Driver.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.ScrollView [1] / android.widget.LinearLayout [1] / android.widget.EditText [2]") .send_keys ("3989441")
Driver.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.ScrollView [1] / android.widget.LinearLayout [1] / android.widget.Button [1]") .click ()
Except:
Pass
# Privacy Protocol
Try:
# Privacy Protocol
If WebDriverWait (driver Lambda x:x.find_element_by_xpath ("/ / android.widget.TextView [@ resource-id='com.tal.kaoyan:id/tv_agree']"): driver.find_element_by_xpath ("/ / android.widget.TextView [@ resource-id='com.tal.kaoyan:id/tv_agree']") .click () br/ > driver.find_element_by_xpath ("/ / android.widget.TextView [@ resource-id='com. Tal.kaoyan:id/tv_agree'] ") .click ()
Except:
Pass
# Click on the inquiry
If WebDriverWait (driver Lambda x:x.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.support.v4.view.ViewPager [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [2] / android.widget.LinearLayout [1] / android.widget.LinearLayout [1] / android.widget.LinearLayout [1] / android.support.v4.view.ViewPager [1] / android.widget.FrameLayout [1] / android.widget.RelativeLayout [1] / android.support.v7.widget.RecyclerView [1] / android.widget.LinearLayout [1] / android.support.v7.widget.RecyclerView [1] / android.widget.RelativeLayout [3] / android.widget.LinearLayout [1] / android.widget.ImageView [1]):
Driver.find_element_by_xpath ("/ / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [1] / android.widget.FrameLayout [1] / android.support.v4.view.ViewPager [1] / android.widget.FrameLayout [1] / android.widget.LinearLayout [2] / android.widget.LinearLayout [1] / android.support V4.view.ViewPager [1] / android.widget.FrameLayout [1] / android.widget.RelativeLayout [1] / android.support.v7.widget.RecyclerView [1] / android.widget.LinearLayout [1] / android.support.v7.widget.RecyclerView [1] / android.widget.RelativeLayout [3] / android.widget.LinearLayout [1] / android.widget.ImageView [1] ") .click ()
L = get_size () x1 = int (l [0] * 0.5) y1 = int (l [1] * 0.75) y2 = int (l [1] * 0.25) # sliding operation while True: driver.swipe Y2) time.sleep (0.5) Note: 1.xpath clicks through uiautomatorviewer to view! [] (https://upload-images.jianshu.io/upload_images/11223715-a88d201baa566c1b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)2.python will report an error if it is loaded with uiautomatorviewer during operation. From appium import webdriver from selenium.webdriver.support.ui import WebDriverWait4 needs to be introduced in the process of using 3.python. The premise is that the appium started: prompt: The server is running! [] (https://upload-images.jianshu.io/upload_images/11223715-b173c522071c521b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)5. There are several tricks to pay attention to: > remote call webdriver.Remote of appium service ("http://localhost:4723/wd/hub",cap)> determines whether if WebDriverWait exists in xpath (driver)" 3) .path (lambda x:x.find_element_by_xpath ("path"): > enter the box to copy driver.find_element_by_xpath ("path"). Send_keys ("fill in data") > button click driver.find_element_by_xpath ("path"). Click () > on the simulation gesture. First get the width and height of the screen, and then from the specified (x1Magi y1) coordinates to (x2) through driver.swipe Y2) def get_size (): X = driver.get_window_size () ['width'] y = driver.get_window_size () [' height'] return (xpeny) l = get_size () x1 = int (l [0] * 0.5) y1 = int (l [1] * 0.75) y2 = int (l [1] * 0.25) driver.swipe (x1Maging y1 X1Magi y2) PS: finally, it realizes how to log in to click on it. Simulate the finger, pull down the loading function.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.