By selenium + pyautogui simulated landing Taobao (perfect realization)

To a continued: because of some other reason, for a long time did not write the code. Recently, originally wanted to be a simulated landing one hundred numbers of simulated landing procedures, but Baidu has been verified rotate the picture did not get, ready to use selenium to complete, and then wanted to find and thought hand, Taobao simulated landing pit on stepping up .

Encountered problems:

Internet hotshots lot different persons, the majority of posts also saw, there are a lot of small next, many of which were not detected by the system through Taobao webdriver, Ethereal way to find the cause, js data back to the server is not the same this much to say. Three do a set of code, the problem is to get after this, there will still annoying slider, and how the operation did not use, transfer speed is not easy, but later found not the reason, when the slider that appears in the positioning element after occurred, so long as there is a similar find_element_by positioning function appears, will be Taobao server anti-climb you, boy, that we do not, I will open a login screen sleep, everything is manual operation, login after acquiring the page information, success! Now the question becomes this part of the manual do not have a way to get selenium, I am also a variety of Baidu, know a man named pyautogui library can be achieved related functions, then sell off now, Combo accidentally success a.

On a simple version of the code, if the process of problem, probably much to install several libraries.

from the Selenium Import webdriver AS wb
 Import pyautogui
 Import PIL
 # Set speed
pyautogui.PAUSE = 0.5 

 # Three lines are switching to developer mode 
Options = wb.ChromeOptions ()
options.add_experimental_option('excludeSwitches', ['enable-automation'])  
browser = wb.Chrome(options=options)

# Window is maximized to ensure the correct coordinates 
browser.maximize_window ()  
browser.get('https://login.taobao.com/member/login.jhtml')

# Find the specified image in the current screen (picture taken by the system needs to FIG screenshot function) 
# 00.jpg good password image is taken 
the coords = pyautogui.locateOnScreen ( ' 00.jpg ' )
 # Obtain an intermediate point to FIG. coordinates 
the X-, the y-= pyautogui.center (coords)
 # left click 
pyautogui.leftClick (the X-, the y-)
 # after switching over here, the cursor directly on the user name there, save a lot of trouble 
pyautogui.typewrite (user name)
 # fill after completion of the user name, the password is a tab to switch 
pyautogui.press ( ' tab ' )
pyautogui.typewrite (password)
# 3.jpg good landing is a screenshot images 
the coords = pyautogui.locateOnScreen ( ' 3.jpg ' )
 # Obtain to FIG intermediate point coordinates 
X, Y = pyautogui.center (the coords)
pyautogui.leftClick (x, y)
# Print html, ok can search your login user name, you can also implement other operations of the 
Print (browser.page_source)

Ha next statement: I am not good at writing blog posts is to see everyone a lot of people stuck in the simulated landing here, wrote a simple, Duokanjibian not read it, I wrote a principle, within two hours to achieve! I wish you success you, give me a shout still do not understand it, we help each other.

 

 

 

Guess you like

Origin www.cnblogs.com/AAA-AAA-AAA/p/11876024.html