Sister graph Crawler. Beginner's crawler

Source: Internet
Author: User
Import re import urllib.request def open_url (URL): req = urllib.request.Request (URL) req.add_header (' User-agent ' , ' mozilla/5.0 (Windows NT 6.1;
    WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/45.0.2454.101 safari/537.36 ') page = Urllib.request.urlopen (req) html = (). Decode (' Utf-8 ') return HTML def get_img (HTML): # # #搜索图片地址 p = R ' \[(. +)] ' Imglist=re.findall (p,html ) return imglist[0] if __name__ = = ' __main__ ': firsturl = ' Http:// ' nowYe = Int (Get_ye (Open_url (Firsturl))) print (' current page:%d '%nowye) while true:ywant = Int (input (' Please enter the page you want to download
                Number: ')) if Ywant<=nowye and ywant >0:for i in Range (ywant): Print    

        url = '' +str (nowye-i) + ' #comments ' get_img (open_url (URL)) break Else:print (' Please re-enter pages: Range in '%d,0 ') '%nowye

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: 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.