Windows环境下批量下载Google图片.pdfVIP

  • 6
  • 0
  • 约1.82千字
  • 约 4页
  • 2017-05-22 发布于河南
  • 举报
Windows环境下批量下载Google图片

Windows 环境下批量下载Google 图片  正文:  Google 的图片搜索功能不可谓不强大,然而要批量下载Google 图片搜索结果也没有什 么现成工具(至少我没有找到可以使用的)。    图  1  本文提供一种在Windows 环境下批量下载Google 搜索结果的方式。  下载并安装安装Python 2.7.3 (注意:Python 3 和Python 2 有较大区别,本文基于Python  2 ),将Python 安装目录加入环境变量Path。    下载Python 脚本文件“get_serch_file.py”。  比如我要下载一些“美女” ,在Google 图片中设置好(如图  1),然后将网页以html 格式 另存到一个目录,并将get_serch_file.py 复制到那个目录。    调出CMD,使用CD 命令定位到此目录。  输入命令:python get_serch_file.py 美女.htm  发现此目录下多了一个thefile.txt的文档,打开并复制其中的连接在迅雷中新建任务便 可以下载了。(也可以用Wget,不过感觉在Windows 下还是没有迅雷方便)      附录:  下载地址:  Python 32bit 下载地址:  /ftp/python/2.7.3/python‐2.7.3.msi  Python 64bit 下载地址:  /ftp/python/2.7.3/python‐2.7.3.amd64.msi  Python 脚本下载地址:  /share/link?shareid=141331uk=3389958815  get_serch_file.py 文件源代码:    #!/usr/bin/python  # ‐*‐ coding: utf‐8 ‐*‐    import sys,os,re    reg=pile(((?=imgurl=)http.*?\.(jpg|gif|png|bmp|jpeg)))  fd=file(sys.argv[1],r)  html=fd.read()  fd.close()  results=reg.findall(html)  file_object=open(thefile.txt,w)  file_object.close()  file_object=open(thefile.txt,w+)  if results:    for one in results:      file_object.write(one[0])      file_object.write(\n)    print done  else:    print empty results  file_object.close() 

文档评论(0)

1亿VIP精品文档

相关文档