如何使用python以字符串形式发送HTTP请求?像这样:
r = """GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.stackoverflow.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive"""
answer = send(r)
print answer # gives me the response as string
假设使用python3,建议您使用urllib.request。 但是由于您特别要求以字符串形式提供HTTP消息, 我假设你想做一些低级的事情,所以你也可以使用http.client:
相关问题 更多 >
编程相关推荐