def request_url(url, referer='http://www.google.com'):
common.plugin.log('request_url : %s' % url)
req = urllib2.Request(url)
req.addheaders = [('Referer', referer),('Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100101 Firefox/11.0 ( .NET CLR 3.5.30729)')]
try:
response = urllib2.urlopen(req)
data = response.read()
response.close()
except urllib2.URLError as e:
common.plugin.log_error("Remote request error for URL %s: %r" % (url,e))
return
except socket.timeout, e:
common.plugin.log_error("Remote request error for URL %s: %r" % (url,e))
return
return data
评论列表
文章目录