The introduction

I looked at the Requests library today. Found and URllib library function similar, very good use, so I wrote a Demo to climb emoticons. I selected some of zhihu’s most favorable answers to the emoticons question, and collected three answers in total, more than 600 emoticons.

The relevant documents

Related procedures: the public account thumb notes background reply “emoticons” obtained.

After installing the relevant library, you only need to change the URL, and you can crawl emojis from other web pages.

Obtaining emoticons: the public account thumb Notes replies to the background “obtaining emoticons”.

I also uploaded the emoticons to the public account, and you can reply to get all the emoticons.

Third-party libraries

Re: regular matching for extracting image information BS4: parsing HTML files urllib: downloading image requests based on extracted connections send HTTP requestsCopy the code

Implementation effect

Here are the memes:


Crawl memes

The whole process is very simple, is the standard crawling static web page process. The first is to determine the location of the information to be climbed, F12 opened to look, quickly determine the location of the picture.

<img src="https://pic1.zhimg.com/80/v2-bffbbe33c937ceb498d0882bf21a651c_720w.jpg">
Copy the code

The next step is to use the BS4 library to parse the page information you get. Four lines of code will do the trick.


Finally, download the image using the URlRetrieve method of the URllib library, and remember to rename each image you download.


The last

If you think this article is ok, please click on it again.