码迷,mamicode.com
首页 > 编程语言 > 详细

python 批量请求url

时间:2016-02-16 16:45:41      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

import urllib2
from urllib import quote

f = open("data.in", "r")
out = file("data2.out","w+")
a = 1.0
for line in f:
        #print line     
        stri = quote(line)
        url =*******+stri 
        #print url
        try:
                data = urllib2.urlopen(url)
        except:
                date = error
        no = str(a)
        out.writelines(no+  + data.read())

        a = a+ 1
        if (a%1000==0):
                print a
        #print data.read()

f.close()

out.close()

 

python 批量请求url

标签:

原文地址:http://www.cnblogs.com/huhuuu/p/5192799.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!