环境
- windows10
- python3.7.3
- selenium
- 谷歌
- 谷歌驱动
谷歌驱动下载
http://chromedriver.storage.googleapis.com/index.html
下载与自己电脑谷歌浏览器版本相应的谷歌驱动
解析
在这里主要爬去商品的基本信息:
结果
代码
from selenium import webdriver
import time
from selenium.webdriver import ActionChains
import csv
f = open('./taobao.csv','a',newline='')
writer = csv.writer(f)
def login(driver):
driver.delete_all_cookies()
url = "https://www.taobao.com/" #https://www.qcc.com/weblogin?back=%2F
driver.get(url)
time.sleep(10)
while True:
try:
driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/ul[2]/li[2]/div[1]/a').click()
break
except:
time.sleep(5)
while True:
try:
driver.find_element_by_xpath('/html/body/div/div[2]/div[3]/div/div/div/div[2]/div/form/div[1]/div[2]/input'