code
import time from splinter.browser import Browser #url = "https://item.jd.com/100013976326.html" def login(b): # login jingdong B.click_link_by_text (" Hello, Sleep (3) b.click_link_by_text(" account login ") b.ill ("loginname"," XXX ") # fill in the account password b.ill ("nloginpwd"," XXX ") b.find_by_id("loginsubmit").click() time.sleep(3) return b def loop(b): try: # b.click_link_by_text(" add to cart ") b.click_link_by_text(BTN) # b.click_link_by_text(" buy now ") if B.test == "Add to cart successfully ": Print (" add to shopping cart successfully ") else: # It may be transferred to the home page of JINGdong after multiple buying operations. So need to open the phone home page print (" snapping up error ") # b.v isit (" https://item.jd.com/6086957.html ") b.v isit (url) # "https://item.jd.com/6063140.html") Time. Sleep (3) # b.click_link_by_text(" add to shopping cart ") # b.click_link_by_text(BTN) except: Print () b.eload () time.sleep(2) loop(b) b=Browser(driver_name= "chrome") in_URL = input \ n ") # https://item.jd.com/14441923664.html btn_name = input (" enter the button name (both in English and Chinese) : \ n ") global url url = in_url b.visit(url)#"https://item.jd.com/6063140.html") global btn btn = btn_name #time.sleep(15) #login(b) time.sleep(20) loop(b)Copy the code
- Tried, “Buy now”, “add to cart” no problem; Some mobile phones and tickets still need to be paid, so you may need to set your alipay or wechat account or bank card account – password in advance. And a button to pay now
- For account security and refund headaches, it is recommended to prioritise specific bank cards and only deposit twice as much as the items you bought (up to a maximum of two) without buying too many. Risk of legal and account closure
May issue
- If you want to use the chrome plugin, download the plugin that matches your browser version and put it directly into the root directory of Chrome and the directory of python’s environment: (below is version 86, the highest currently support 87, is not too stable, other versions can click the parentDirectory to the server directory to find). Chromedriver.storage.googleapis.com/index.html?…
C:\Program Files (x86)\Google\Chrome\Application Chrome;
! [](https://p1.pstatp.com/origin/pgc-image/0f5d914e29684cc284406ee64759acb5)
- Recommended Chrome browser, note that the drive version and the default chrome version should be consistent, (generally 86 version, a few 87, Chrome upper right corner “help” about Chrome inside can be checked.
PS: If you need Python learning materials, please click on the link below to obtain them
Free Python learning materials and group communication solutions click to join