python有没有办法将整个html页面及其内容(图像,css)下载到给定URL的本地文件夹.并更新本地html文件以在本地选择内容.
我查看了Google及其档案.有几篇好文章,但似乎都没有帮助我.所以我想我会来这里寻求更具体的答案.
目标:我想在网站上运行此代码以立即获取所有图片文件.它会节省很多指点和点击.
我在Windows 7 x64机器上安装了Python 2.3.5.它安装在C:\ Python23中.
如何让这个脚本"去",可以这么说?
=====================================
哇.35k次观看.看看这是如何在谷歌的最佳结果,这是我多年来发现的有用链接:
http://learnpythonthehardway.org/book/ex1.html
有关设置,请参阅练习0.
=====================================
仅供参考:我对Python没有经验.任何意见,将不胜感激.
根据要求,这是我正在使用的代码:
"""
dumpimages.py
Downloads all the images on the supplied URL, and saves them to the
specified output file ("/test/" by default)
Usage:
python dumpimages.py http://example.com/ [output]
"""
from BeautifulSoup import BeautifulSoup as bs
import urlparse
from urllib2 import urlopen
from urllib import urlretrieve
import os
import sys
def main(url, out_folder="C:\asdf\"):
"""Downloads all the images at 'url' to /test/"""
soup = bs(urlopen(url))
parsed …Run Code Online (Sandbox Code Playgroud) 我通常使用WGET从某个网页下载一两个图像,我从命令提示符处执行以下操作:wget 'webpage-url' -P 'directory to where I wanna save it'.现在我如何在Perl和Python中自动化它?这是什么命令使我能够模拟,好像我在命令提示符下输入命令?在Python中有很多类似的模块,如subprocess,os等,我很困惑.