- 论坛徽章:
- 4
|
肯定是可以带refer的
test = GetUrl()
result, ret = test.RequestUrl("http://www.artxun.com", None, Referer = "www.baidu.com")
print ret
GET / HTTP/1.1
Accept-Encoding: identity
Host: www.artxun.com
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
Connection: close
Referer: www.baidu.com
Pragma: no-cache
Cache-Control: no-cache
这个是我抓包抓的http请求包
还有就是原来代码里面for k, v in headers.items(): 写错了 items后面掉了括号
for k, v in headers.items:
if type(k) == types.StringType and type(v) == types.StringType:
request.add_header(k, v)
改为 for k, v in headers.items():
request.add_header(str(k), str(v))
嘿嘿 |
|