Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I download a website using python 3?

Just an http get request like file_get_contents in php, or something simple where I enter URL and it get contents to variable.

like image 308
ForeverConfused Avatar asked Dec 19 '10 21:12

ForeverConfused


1 Answers

Use urllib:

from urllib.request import urlopen
html = urlopen("http://www.stackoverflow.com/").read().decode('utf-8')
print(html)
like image 186
alexn Avatar answered Oct 29 '22 23:10

alexn