|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 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[len(zmu)-1]
- 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)[0]
- except :
- print "任务完成!".decode("u8")
- break
- url=ur+dd
复制代码
有很多人写了,我写一个。
后续在发处理程序。 |
|