python get html code code example
Example 1: python how to get html code from url
import urllib.request #pip install concat("urllib", number of current version)
my_request = urllib.request.urlopen("INSERT URL HERE")
my_HTML = my_request.read().decode("utf8")
print(my_HTML)
Example 2: python get webpage source
import requests
url = input('Webpage to grab source from: ')
html_output_name = input('Name for html file: ')
req = requests.get(url, 'html.parser')
with open(html_output_name, 'w') as f:
f.write(req.text)
f.close()