开发者

How do I download a website using python 3?

Just an http get request like file_get_conten开发者_如何学JAVAts in php, or something simple where I enter URL and it get contents to variable.


Use urllib:

from urllib.request import urlopen
html = urlopen("http://www.stackoverflow.com/").read().decode('utf-8')
print(html)


Your Intention seems to be to get a static version of a Website. This can be achieved using WGET. This tool can in one command retrieve the files for a given URL. Use the -r (recursive) Parameter with care, example:

wget -erobots=off -p -H -k -E -w 1 --random-wait -r -l 1 http://your.site.

Download a working local copy of a webpage

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜