00aa's recent timeline updates
00aa

00aa

V2EX member #249001, joined on 2017-08-16 15:08:22 +08:00
00aa's recent replies
Aug 21, 2017
Replied to a topic by 00aa Python 萌新关于 Python 爬虫方面的问题
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。避免网页验证
Aug 18, 2017
Replied to a topic by 00aa Python 萌新关于 Python 爬虫方面的问题
nobody ?
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2673 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms · UTC 15:59 · PVG 23:59 · LAX 08:59 · JFK 11:59
♥ Do have faith in what you're doing.