- 论坛徽章:
- 0
|
#!/usr/bin/python
# -*- coding:utf-8 -*-
import urllib2
header = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
req = urllib2.Request(
url= "https://www.google.com.hk/search?num=100&hl=zh-CN&newwindow=1&safe=strict&q=inurl%3Aadmin_login.aspx&oq=inurl%3Aadmin_login.aspx&gs_l=serp.3...125521.131943.0.132041.38.31.1.0.0.3.209.2367.23j3j1.27.0...0.0...1c.1.bvH-WnKtKjg",headers = header
)
r = urllib2.urlopen(req).read()
print r
代码如上,我需要伪造http来访问这个连接。可是出现了以下错误:
File "C:\Python27\lib\urllib2.py", line 615, in http_error_302
self.inf_msg + msg, headers, fp)
urllib2.HTTPError: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Found |
|