Skip to content

Instantly share code, notes, and snippets.

@froop
Created September 25, 2021 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save froop/9dc5c0a76cf24c22cd03c26c3497c815 to your computer and use it in GitHub Desktop.
Save froop/9dc5c0a76cf24c22cd03c26c3497c815 to your computer and use it in GitHub Desktop.
[Python] HTTP GET minimum (Python 2.7)
import httplib
con = httplib.HTTPConnection('172.31.1.12', 80)
con.request('GET', '/')
res = con.getresponse()
print(res.status)
import requests
res = requests.get('http://172.31.1.12/')
print(res.status_code)
import urllib2
req = urllib2.Request('http://172.31.1.12/')
res = urllib2.urlopen(req)
print(res.getcode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment