Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to automatically grab the mobile phone on JD.com in Python

Shulou Source: shulou.com Published: 2022-05-31 11:18:41 11月17日 Update

This article introduces the relevant knowledge of "how to automatically grab JD.com 's mobile phone on Python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

#-*-Encoding: UTF-8-*-

From splinter. Browserimportbrowser

Importtime

Deflogin (b):

B.click_link_by_text ('account login')

Sleep time (1)

Fill in ('login', 'XXX') # JD.COM user name

Sleep time (1)

B. Fill in ('nloginpwd', 'XXX') # login password

Sleep time (1)

B.find_by_id ('loginsubmit'). Click ()

Printb

Return to b

# order Page

Reverse loop (b): # loop click

Try:

Ifb.title==' order settlement Page-JD.COM Mall':

B.find_by_text ('save consignee information'). Click ()

B.find_by_text ('Save payment and delivery method'). Click ()

B.find_by_id ('order-submit'). Click ()

Return to b

After many capture operations, Else:# may be transferred to the home page of JD.COM, so you need to reopen the home page of the phone.

b. Visit ('https://item. JD.com/4461470. Html') # URL of Glory V9

B.find_by_id ('choose-btn-qiang'). Click ()

Sleep time (1)

Loop (b) # Recursive operation

Exceptionexception: # avoid interrupting exception handling of the program

B.reload () # refresh the current page, that is, order submission page

Sleep time (1)

Loop (b) # call itself again

B = browser ()

B. Visit ('https://item.jd.com/4461470.html')

Sleep time (10)

B.click_link_by_text ('hello, please log in')

Sleep time (5)

B = login (b) # login

Sleep time (1)

WhileTrue:

Cycle (b)

IFB. Is _ element _ present _ by _ id ('try BTN'): # shows "snap up again" after the order is submitted.

B.find _ by _ id ('try BTN'). Click () # Click to snap up again, enter the countdown 5 and jump to the order page

time。 Sleep (6.5)

Elifb.title==' order settlement page-JD.COM Mall': # if it is still on the order settlement page

B.find_by_id ('order-submit'). Click ()

Else:

Print ("Congratulations, successful capture")

What are the advantages of Python: 1. Easy to use. Compared with traditional languages such as Java, Java and C #, Python has less strict requirements on code format. 2. Python is open source and everyone can see the source code and can be ported to many platforms. 3. Python is object-oriented and can support both process-oriented programming and object-oriented programming. 4. Python is an explanatory language, the program written by Python does not need to be compiled into binary code, and can be run directly from the source code; 5. Python is powerful and has many modules, which can basically achieve all the common functions.

This is the end of the content of "how to automatically grab JD.com 's mobile phone on Python". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Time sleep order login page loop mobile phone again program settlement code content function mall object more source code knowledge language process Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn MySQL OPPO Reno Apple