Created
September 11, 2017 18:02
-
-
Save mateisuica/3bd789b11bd5650a9aec0b90466dc001 to your computer and use it in GitHub Desktop.
Load a webpage content in Python
This file contains 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 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