下载html页面及其内容 [英] Download html page and its content
问题描述
python是否有任何方式将整个html页面及其内容(图像,css)下载到本地文件夹中给出一个url。并更新本地html文件以在本地选取内容。
python.org/library/urllib.htmlrel =noreferrertitle =Python文档> urllib
模块下载单个URL,但是这只会返回数据。它不会解析HTML并自动下载CSS文件和图像等。 如果你想下载整个页面,你需要解析HTML并找到你需要下载的其他东西。您可以使用美丽的汤来解析您检索的HTML 。
这个问题有一些示例代码正是这样做的。
Does python have any way of downloading entire html page and its contents (images, css) to local folder given a url. And updating local html file to pick content locally.
You can use the urllib
module to download individual URLs but this will just return the data. It will not parse the HTML and automatically download things like CSS files and images.
If you want to download the "whole" page you will need to parse the HTML and find the other things you need to download. You could use something like Beautiful Soup to parse the HTML you retrieve.
This question has some sample code doing exactly that.
这篇关于下载html页面及其内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!