我希望从http://abc.com/view_page.aspx?ID=下载多个HTML页面,ID是不同数字的数组。
我想访问多个此URL实例,并使用不同的代理IP/端口将文件保存为[ID].HTML。
我想使用不同的用户代理,并在每次下载之前随机等待时间。
最佳方法是什么? urllib2? pycURL? cURL?你喜欢手头的任务用哪一个?
请给予建议。谢谢大家!
我希望从http://abc.com/view_page.aspx?ID=下载多个HTML页面,ID是不同数字的数组。
我想访问多个此URL实例,并使用不同的代理IP/端口将文件保存为[ID].HTML。
我想使用不同的用户代理,并在每次下载之前随机等待时间。
最佳方法是什么? urllib2? pycURL? cURL?你喜欢手头的任务用哪一个?
请给予建议。谢谢大家!
使用类似以下的内容:
import urllib2
import time
import random
MAX_WAIT = 5
ids = ...
agents = ...
proxies = ...
for id in ids:
url = 'http://abc.com/view_page.aspx?ID=%d' % id
opener = urllib2.build_opener(urllib2.ProxyHandler({'http' : proxies[0]}))
html = opener.open(urllib2.Request(url, None, {'User-agent': agents[0]})).read()
open('%d.html' % id, 'w').write(html)
agents.append(agents.pop()) # cycle
proxies.append(proxies.pop())
time.sleep(MAX_WAIT*random.random())
wget
进行基本的网页抓取,所以很抱歉,我无法为您提供更多关于代理的信息。 - pajtonsetenv http_proxy=http://proxy.example.com:8080;
wget --proxy-user=foo --proxy-password=bar --user-agent="Frobzilla/1.1" [url]
- wump