from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
things = input("请输入您要查询的商品:")
driver = webdriver.Chrome()
driver.implicitly_wait(5)
def scan_login(url):
driver.get(url)
# 等待扫码登录
time.sleep(15)
#跳过滑动验证
chrome_option = webdriver.ChromeOptions()
chrome_option.add_argument('--proxy--server=127.0.0.1:8080')#使用代理IP,告诉服务器这是人为操作
search = driver.find_element_by_xpath('//*[@id="q"]') #在kw内输入
search.send_keys(things)#获取输入的商品
time.sleep(2)
search.send_keys(Keys.ENTER)#按回车
time.sleep(6)#大约加载6秒
print (driver.page_source)#打印网页源码
if __name__ == '__main__':
url = 'https://login.taobao.com/member/login.jhtml'#淘宝登录页面
scan_login(url)