【python爬虫】scrapy入门2--自定义item
2024-10-09 03:43:03
items.py
class LianhezaobaospyderItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
# pass
body=scrapy.Field()
link=scrapy.Field()
爬虫.py
from .. import items def parse_news(self,response):
item=items.LianhezaobaospyderItem()
item['body']=response.xpath("//div[@class='xx']/text()").get()
item['link']=response.url
yield item
item和字典类似,数据量大时,字典可能键值对错误
最新文章
- Coursera台大机器学习课程笔记6 -- The VC Dimension
- delphi.数据结构.链表
- spring MVC学习笔记
- 【转】深入理解const char*p,char const*p,char *const p,const char **p,char const**p,char *const*p,char**const p
- jquery 温故而知新 Ul 相关的操作
- codeforces 361 D - Friends and Subsequences
- 你不知道的This和Class
- mac os 系统密码正确的 但是进不了系统
- 【转】一个windows线程池实现
- 大表 update 方式
- C++----练习--while求和
- px-rem自适应转换
- 学习笔记6-Android查看应用输出的错误信息 如何部署应用到真实手机 发布软件
- PS抠图简单粗暴2种方法
- Jenkins自动化部署-----持续交付【转】
- scapy 中的ARP
- windows删除文件或目录CMD命令
- Delphi: TLabel设置EllipsisPosition属性用...显示过长文本时,以Hint显示其全文本
- go语言中的坑
- Hive在drop表的时候报错
热门文章
- Vue Cli 报错:You are using the runtime-only build of Vue where the template compiler is not availabl
- TCP连接过程及报文解析
- “Too many texture interpolators would be used for ForwardBase pass”
- python 类C数组的两种形式:list -->内容可变, tuple --->内容不可变
- 华为设备RIP实施和理论详解
- JAVA大数几算--HDU 2054 A == B ?
- python(类多态)
- HBase Filter 过滤器之RowFilter详解
- 手写实现java栈结构,并实现简易的计算器(基于后缀算法)
- turtle库应用实例-五角星绘制