[Python] [crawler] Burst gif download

Source: Internet
Author: User

Description: And the previous download Baidu posted pictures almost, modified the regular, added page control;
In addition to the output format control, if you want to join the manual set storage path function, you can refer to the previous Baidu paste stick crawler

#!/usr/bin/env python#!-*-coding:utf-8-*-#图片地址样例: src= "http://ww2.sinaimg.cn/large/005Yan1vjw1erf95qkbfog307e08uu0y.gif" style= "width:460px"ImportUrllib,urllib2ImportRe#返回网页源代码 def gethtml(URL, page):Tempurl = URL + str (page)PrintTempurl html = urllib2.urlopen (tempurl) Srccode = Html.read ()returnSrccode def getimg(URL, start_page, end_page):    #对网页中图片建立正则Pattern = Re.compile (R ' src= "(. *?\.gif)". *?style= "width:460px" ') forXinchXrange (Start_page, end_page+1): Srccode = gethtml (url,x)#图片完整路径存储为listIMGSRC = Pattern.findall (srccode) num =0         forIinchImgSrc:urllib.urlretrieve (I,' P%s0%s.gif '% (x, num)) num + =1            Print "Regular Download"            PrintIPrint ' All Tasks done! '#-----------The entrance to the program-----------Print u "" "Program starts running #=========================================================# program: Mob Crawler # version: v0.1# before cloud # language: Python 2.7# Action: Enter the range of page numbers for the burst gif you want to download, and automatically download all GIF images #========================================================= "" "#测试urlMyurl =' http://baozoumanhua.com/gif/hot/page/'start_page = Int (Raw_input (u "input start page \ n")) end_page = Int (Raw_input (u "Enter end page \ n")) getimg (Myurl, Start_page, End_page)

[Python] [crawler] Burst gif download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.