Skip to content

Instantly share code, notes, and snippets.

@mateisuica
Created September 11, 2017 18:02
Show Gist options
  • Save mateisuica/3bd789b11bd5650a9aec0b90466dc001 to your computer and use it in GitHub Desktop.
Save mateisuica/3bd789b11bd5650a9aec0b90466dc001 to your computer and use it in GitHub Desktop.
Load a webpage content in Python
import urllib.request
def loadPage( site ):
hdr = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','User-Agent':'Mozilla/5.0'}
request=urllib.request.Request(site,None,hdr) #The assembled request
response = urllib.request.urlopen(request)
page = response.read() # The data u need
return page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment