python 网页小说爬虫。
本帖最后由 s1986q 于 2015-7-1 19:23 编辑import httplib,re,os
if os.path.isdir(r"e:\\html\\")<>1:
os.mkdir("e:\\html\\")
f=open("e:\\html\\17182420.html","w")
f.close()
def getapost(url):
host="m.7gxs.com"
port=80
global dat
dat=""
data={"Cookie:":dat}
fd=httplib.HTTPConnection(host,port)
fd.request("GET",url,"",data)
gh=fd.getresponse()
dat=gh.getheader("set-cookie","")
jj=gh.read()
return jj
zmu=os.listdir("e:\\html\\")
dd=zmu
ur="http://www.shuhaha.com/Html/Book/66/66595/"
url=ur+dd
while True :
print dd
htm=getapost(url)
f = open("e:\\html\\"+dd,"w")
f.write(htm)
f.close()
try:
dd=re.findall(r"var nextpage=\"(\d+\.html)\"",htm)
except :
print"任务完成!".decode("u8")
break
url=ur+dd
有很多人写了,我写一个。
后续在发处理程序。 。。。。。。。。。 可以的 楼主给力!{:10_256:}默默的收下,然后再改造!
页:
[1]