下载HTML页面及其内容 [英] Download HTML page and its contents
问题描述
Python 是否可以将整个HTML
页面及其内容( images,css )下载到给定URL的本地文件夹中.并更新本地html文件以在本地选择内容.
Does Python have any way of downloading an entire HTML
page and its contents (images, css) to a 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.
如果要下载整个"页面,则需要解析HTML并找到需要下载的其他内容.您可以使用Beautiful Soup 之类的方法来解析检索到的HTML
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屋!