Python crawler Primer-scrapy Basic use

Source: Internet
Author: User
Tags xpath

Source: Link: Password: 9flo
Create Project Scrapy startproject Tutorial Crawl scrapy crawl D Moz Crawl and Save as JSON format Scrapy crawl Dmoz-o items.json-t JSON
scrapy Shell "url/resource" will be able to get response response after loading Response.bodyresponse.headers>>>response.xpath ('//title ') > >>response.xpath ('//title/text () '). Extract ()

Edit Item:
  1. # -*- coding: utf-8 -*-
  2. # Define here the models for your scraped items
  3. #
  4. # See documentation in:
  5. #
  6. import scrapy
  7. class DmozItem(scrapy.Item):
  8. # define the fields for your item here like:
  9. # name = scrapy.Field()
  10. title = scrapy.Field()
  11. link = scrapy.Field()
  12. desc = scrapy.Field()

Edit spider: Crawl and Save as JSON format here, there will be a JSON file in the root directory


Python crawler Primer-scrapy Basic use

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