Use the Python Scrapy framework to crawl the beauty chart in ten minutes, pythonscrapy
Introduction
Scrapy is a python crawler framework with rich functions and convenient use. Scrapy can be used to quickly develop a simple crawler. An official simple example is enough to prove its strength:
Quick Development
The next 10-minute countdown starts:
Of course, before you start, you can first read the scrapy getting started article "Writing python crawlers using the Scrapy framework ".
1. initialize the project
scrapy startproject mztcd mztscrapy genspider meizitu meizitu.com
2. Add the spider code:
Define scrapy. Item and add image_urls and images to prepare for downloading the image.
Modify start_urls as the initial Page, add parse to process the list page, and add parse_item to process the project page.
3. modify the configuration file:
DOWNLOAD_DELAY = 1 # Add the download delay configuration ITEM_PIPELINES = {'scrapy. pipelines. images. ImagesPipeline ': 1} # Add an image download pipelineIMAGES_STORE ='. '# Set the image storage directory
4. Run the project:
scrapy crawl meizitu
See, project run
Wait for a while, it's time to reap
Summary
The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.