Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中。  具体开发流程如下:

  一、确定待抓取网站

当您需要从某个网站中获取信息,但该网站未提供API或能通过程序获取信息的机制时, Scrapy可以助你一臂之力。

 二、定义要抓取的数据

定义我们需要爬取的数据。在Scrapy中, 这是通过 Scrapy Items 来完成的。(在本例子中为种子文件)

我们定义的Item:

1 # Define here the models for your scraped items 2 # 3 # See documentation in: 4 # http://doc.scrapy.org/topics/items.html 5 6 from scrapy.item import Item, Field 7 8 class TutorialItem(Item): 9 # define the fields for your item here like: 10 # name = Field() 11 title=Field() 12 link=Field() 13 desc=Field() 14 15 16
View Code

相关文章:

  • 2021-12-10
  • 2021-12-05
  • 2021-05-31
  • 2022-01-18
  • 2021-05-07
  • 2021-08-23
  • 2021-09-08
  • 2021-09-11
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2022-03-04
  • 2021-11-11
  • 2022-01-15
  • 2022-12-23
相关资源
相似解决方案