Last active
December 16, 2015 06:59
-
-
Save yuuichi-fujioka/5395327 to your computer and use it in GitHub Desktop.
http request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
def http_req(host, port = 80, method = 'GET', uri = '', headers = {}, body=''): | |
con = httplib.HTTPConnection(host, port) | |
con.request(method, uri, body, headers) | |
resp = con.getresponse() | |
if resp.status == httplib.OK : | |
print resp.read() | |
else: | |
print 'Error Status=%(status)d Message=%(msg)s'%{'status':resp.status, 'msg':resp.read()} | |
con.close() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
resp = requests.get('http://www.yahoo.co.jp') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment