GET 

#!/usr/bin/env python
# encoding: utf-8
import urllib
import urllib2

url = "http://127.0.0.1/index.php?a=hello world"
request = urllib2.Request(url=url)
response =urllib2.urlopen(request,timeout=20)
result = unicode(response.read())
print result

POST

# encoding: utf-8
import urllib
import urllib2

url = "http://127.0.0.1/index.php"
par = urllib.urlencode({'a':1})
request = urllib2.Request(url)
opneer = urllib2.build_opener(urllib2.HTTPCookieProcessor())#所必须的
response = opneer.open(request,par)
result = response.read()
print result

 

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2021-10-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案