最简单模拟登陆淘宝

不用其他别的库,就用selenuim

先用微博绑定淘宝再用以下代码,就可以了

 1 from selenium import webdriver
 2 from selenium.webdriver import ChromeOptions
 3 import time
 4 option = ChromeOptions()
 5 
 6 option.add_experimental_option('excludeSwitches', ['enable-automation'])
 7 driver = webdriver.Chrome('chromedriver.exe', options=option)
 8 
 9 driver.get('https://www.taobao.com/')
10 driver.maximize_window()
11 
12 driver.find_element_by_xpath('//*[@id="J_SiteNavLogin"]/div[1]/div[1]/a[1]').click()
13 driver.find_element_by_xpath('//*[@id="J_QRCodeLogin"]/div[5]/a[1]').click()
14 driver.find_element_by_xpath('//*[@id="J_OtherLogin"]/a[1]').click()
15 time.sleep(2)
16 driver.find_element_by_class_name('username').click()
17 driver.find_element_by_xpath('//*[@id="pl_login_logged"]/div/div[2]/div/input').send_keys('微博账号')
18 time.sleep(1)
19 driver.find_element_by_class_name('password').click()
20 driver.find_element_by_xpath('//*[@id="pl_login_logged"]/div/div[3]/div/input').send_keys('微博密码')
21 time.sleep(1)
22 driver.find_element_by_xpath('//*[@id="pl_login_logged"]/div/div[7]/div[1]/a').click()
23 driver.find_element_by_xpath('//*[@id="q"]').send_keys('python')
24 driver.find_element_by_xpath('//*[@id="J_TSearchForm"]/div[1]/button').click()

猜你喜欢

转载自www.cnblogs.com/liyaobin/p/10948606.html
今日推荐