import os
import selenium.webdriver as webdriver
driver=webdriver.Chrome()
import xlrd
data = xlrd.open_workbook("C://Python27//2.xlsx")
table = data.sheets()[0]
nrows = table.nrows
ncols = table.ncols
rowValues=[]
for i in xrange(0,nrows):
rowValues.append(table.row_values(i))
a=[]
for r in rowValues:
s = ('').join(r)
base_url = '
http://www.qichacha.com/search?key=' + s
a.append(base_url)
res=[]
for r in a:
driver.get(r)
results=driver.find_elements_by_xpath("//tr[1]//td[2]/p[1][@class='m-t-xs']/a")
for result in results:
res.append(result.text)
from xlutils.copy import copy
from xlrd import open_workbook
from xlwt import easyxf
excel=r'C://Python27//2.xlsx'
rb=xlrd.open_workbook(excel)
wb=copy(rb)
sheet=wb.get_sheet(0)
x=0
y=5
for tag in res:
sheet.write(x,y,tag)
x+=1
wb.save(excel)
大概是这样的过程,怎么去使用代理 ip。避免网页验证