我正在写一个代码来获得一个域名列表谷歌Pagerank。经过一段时间和一定数量的查询,我的IP被列入黑名单,现在我得到了HTTP错误403。我的问题是如何添加到脚本中,以便每隔几秒从我正在使用的测量服务器上的ip池更改ip地址。有人能帮忙吗?在
from __future__ import print_function, division
import sys
import urllib.request as _urlib1 # py3
import urllib.parse as _urlib2 # py 3
def get_pagerank(url):
hsh = check_hash(hash_url(url))
gurl = 'http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank&ch=%s&q=info:%s' % (hsh, _urlib2.quote(url))
u = _urlib1.urlopen(gurl)
s = u.read().decode('utf-8') # for py2, comment .decode() part
#print(s) # debug - response of server
rank = s.strip()[9:]
if rank == '':
rank = 'None'
if rank == 'None':
rank = 'None'
return rank
这是我的代码:
在Linux下,对于一个接口eth0:
您必须从python中以命令的形式启动它,然后从可用ip列表中依次更改newaddress
您可以使用以下命令运行命令:
^{pr2}$要在周期性时间执行此操作,请使用线程或celery
相关问题 更多 >
编程相关推荐