The code can be understood in two ways . Part of it is through python Of selenium Library to automate interaction with web pages , The other part is to log in with the help of the website platform , It can be realized by sending the mobile phone verification code ,
In the first aspect, it should be noted that , When I crawl to get website elements, I use By.xpath This method . and xpath Is the least recommended , Because as long as the website changes a little , The code will fail . Many can be changed to id perhaps class_name. But sometimes class_name Not necessarily the only , This needs attention , Is there a solution ? It can be obtained through the parent node or child node
def kuaishou(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe")# Store your own webdriver The path of driver.get ( "<https://www.kuaishou.com/?utm_source=bb&utm_medium=01&utm_campaign=MIXED_HAO123_DC_XXL_CPT&location=01_mingzhan_2_7>" ) driver.maximize_window() sleep(0.5) driver.find_element_by_class_name('user-default').click() driver.find_element_by_class_name('pl-input-text').send_keys(phone) driver.find_element_by_class_name('get-verification').click() sleep(1) driver.quit()
def tonhcheng58(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://passport.58.com/reg/?path=https%3A%2F%2Fsu.58.com%2F%3Futm_source%3Dmarket%26spm%3Db-31580022738699-me-f-862.mingzhan&source=58-homepage-pc&utm_source=market&spm=b-31580022738699-me-f-862.mingzhan&PGTID=0d100000-0000-5c8d-b15b-7e4b9a57dc48&ClickID=2>" ) driver.maximize_window() sleep(0.5) driver.find_element_by_id('mask_body_item_phonenum').send_keys(phone) driver.find_element_by_id('mask_body_item_getcode').click() sleep(1) driver.quit()
When I was crawling the website , Deliberately avoid the verification code problem . Because the processing time and accuracy of the verification code can not bear to look directly , Identify three successes and one success . If there is a small partner who wants to add a verification code to the website , have access to tesseract, I will post the official website link below .
from selenium import webdriver from time import sleep phone = 000000# Your target mobile number number = 1000# Number of bombings def kuaishou(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe")# Store your own webdriver The path of , The following items need to be changed driver.get ( "<https://www.kuaishou.com/?utm_source=bb&utm_medium=01&utm_campaign=MIXED_HAO123_DC_XXL_CPT&location=01_mingzhan_2_7>" ) driver.maximize_window() sleep(0.5) driver.find_element_by_xpath('//*[@id="app"]/div[1]/section/div/div/header/div/div[3]/ul/li[3]/div/p').click() driver.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div/div/div[1]/div/div[1]/div/input').send_keys(phone) driver.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div/div/div[1]/div/div[2]/div/div/span').click() sleep(1) driver.quit() def TaoBao(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://reg.taobao.com/member/reg/fast/union_reg?_regfrom=TB>" ) driver.maximize_window() sleep(0.5) driver.find_element_by_xpath('//*[@id="container"]/div/div[2]/div[1]/div/div/div[2]/input').send_keys(phone) driver.find_element_by_xpath('//*[@id="container"]/div/div[2]/div[2]/div/div/div[2]/a').click() sleep(1) driver.quit() def tonhcheng58(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://passport.58.com/reg/?path=https%3A%2F%2Fsu.58.com%2F%3Futm_source%3Dmarket%26spm%3Db-31580022738699-me-f-862.mingzhan&source=58-homepage-pc&utm_source=market&spm=b-31580022738699-me-f-862.mingzhan&PGTID=0d100000-0000-5c8d-b15b-7e4b9a57dc48&ClickID=2>" ) driver.maximize_window() sleep(0.5) driver.find_element_by_xpath('//*[@id="mask_body_item_phonenum"]').send_keys(phone) driver.find_element_by_xpath('//*[@id="mask_body_item_getcode"]').click() sleep(1) driver.quit() def gaodun(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://www.gaodun.com/>" ) driver.maximize_window() sleep(0.5) driver.find_element_by_xpath('//*[@id="applyLoginId"]').click() driver.find_element_by_xpath('//*[@id="js_changeOtherType"]').click() driver.find_element_by_xpath('//*[@id="js_GaodunLoginOrderPhone"]').send_keys(phone) driver.find_element_by_xpath('//*[@id="js_GaodunLoginPullCode"]').click() sleep(1) driver.quit() def yidong(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://login.10086.cn/login.html?channelID=12003&backUrl=https://shop.10086.cn/i/?f=home>" ) driver.maximize_window() sleep(0.5) driver.find_element_by_xpath('//*[@id="J_pc"]').click() # driver.find_element_by_id("hr_label_phonelogin").click() driver.find_element_by_xpath('//*[@id="sms_name"]').send_keys(phone) driver.find_element_by_xpath('//*[@id="getSMSPwd1"]').click() sleep(2) driver.quit() def liepin(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://www.liepin.com/>" ) driver.maximize_window() sleep(1.5) driver.find_element_by_xpath('//*[@id="tel"]').send_keys(phone) # sleep(2) driver.find_element_by_xpath('//*[@id="home-banner-login-container"]/div/div/div/div/div[3]/div/form/div[2]/div/div/div/span/span/span/div').click() sleep(1) driver.quit() def migu(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://passport.migu.cn/portal/user/register/msisdn?sourceid=220001&callbackURL=https%3A%2F%2Fmusic.migu.cn%2Fv3>" ) driver.maximize_window() sleep(1.5) driver.find_element_by_xpath('/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div/a').click() # sleep(1) driver.find_element_by_xpath('//*[@id="J_Phone"]').send_keys(phone) # sleep(1) driver.find_element_by_xpath('//*[@id="J_GetMsgCode"]').click() sleep(1) driver.quit() def xueqiu(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://xueqiu.com/>" ) driver.maximize_window() sleep(2) # driver.find_element_by_xpath('//*[@id="app"]/nav/div[1]/div[2]/div/div/span').click() driver.find_element_by_xpath('/html/body/div[2]/div[1]/div/div/div/div[2]/div[1]/div[1]/div[1]/a[1]').click() sleep(1) driver.find_element_by_xpath('/html/body/div[2]/div[1]/div/div/div/div[2]/div[1]/div[1]/div[2]/div/div/form/div[1]/input').send_keys(phone) sleep(1) driver.find_element_by_xpath('/html/body/div[2]/div[1]/div/div/div/div[2]/div[1]/div[1]/div[2]/div/div/form/div[1]/span[2]').click() sleep(1) driver.quit() def ku6(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://video-center.ku6.com/video-center/user/register>" ) driver.maximize_window() sleep(1.5) driver.find_element_by_xpath('//*[@id="phone"]').send_keys(phone) # sleep(1) driver.find_element_by_xpath('//*[@id="codeBut"]').click() sleep(1) driver.quit() def newpianchang(): driver = webdriver.Chrome(r"C:\\\\Users\\\\86151\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe") driver.get ( "<https://passport.xinpianchang.com/signup?redirect_uri=https%3A%2F%2Fwww.vmovier.com%2F>" ) driver.maximize_window() sleep(1.5) driver.find_element_by_xpath('//*[@id="signup_nickname"]').send_keys('saodoiad7987') driver.find_element_by_xpath('//*[@id="signup_phone"]').send_keys(phone) # sleep(1) driver.find_element_by_xpath('//*[@id="__next"]/section/main/div[2]/div/div/div/form/div[3]/div/div/span/span/span/span/a').click() sleep(1) driver.quit() for i in range(number): kuaishou() print("{} The first {} Time Send successfully {}".format(phone,i," Well quickly ")) TaoBao() print("{} The first {} Time Send successfully {}".format(phone,i," TaoBao ")) tonhcheng58() print("{} The first {} Time Send successfully {}".format(phone,i,"58 Same city ")) gaodun() print("{} The first {} Time Send successfully {}".format(phone,i," Gordon Education ")) yidong() print("{} The first {} Time Send successfully {}".format(phone,i," Move ")) liepin() print("{} The first {} Time Send successfully {}".format(phone,i," Liepin ")) migu() print("{} The first {} Time Send successfully {}".format(phone,i," Gumi music ")) xueqiu() print("{} The first {} Time Send successfully {}".format(phone,i," Snowball ")) ku6() print("{} The first {} Time Send successfully {}".format(phone,i," cool 6 video ")) newpianchang() print("{} The first {} Time Send successfully {}".format(phone,i," New film studio "))
Python Use fitter Then you wil
Chen Tuo 2022/06/10-2022/06/11