Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python 3下载网站?_Python_Python 3.x - Fatal编程技术网

如何使用python 3下载网站?

如何使用python 3下载网站?,python,python-3.x,Python,Python 3.x,只是一个http get请求,比如php中的file_get_contents,或者我输入URL并将内容获取到变量的简单方法。使用: 您的意图似乎是获取网站的静态版本。这可以使用WGET实现。此工具可以通过一个命令检索给定URL的文件。 小心使用-r(递归)参数,例如: wget-erobots=off-p-H-k-E-w1——随机等待-r-l1 你不能假设它是UTF-8,真的。要么不解码,要么检查标题。这只会得到HTML。有没有办法获取图像和外部js文件等?或者我们只是浏览html并查找标签,

只是一个http get请求,比如php中的file_get_contents,或者我输入URL并将内容获取到变量的简单方法。

使用:


您的意图似乎是获取网站的静态版本。这可以使用WGET实现。此工具可以通过一个命令检索给定URL的文件。 小心使用-r(递归)参数,例如:

wget-erobots=off-p-H-k-E-w1——随机等待-r-l1


你不能假设它是UTF-8,真的。要么不解码,要么检查标题。这只会得到HTML。有没有办法获取图像和外部js文件等?或者我们只是浏览html并查找标签,因为在一些需要一段时间的网站上,CertVerificationError是通过使用
导入请求来解决的
from urllib.request import urlopen
html = urlopen("http://www.stackoverflow.com/").read().decode('utf-8')
print(html)