首页 > 解决方案 > 提炼

用 Scrapy

问题描述

如何<header></header>使用 Scrapy 从页面中提取所有内容?我试过这个,但无济于事:response.css('header')

另外,我需要<img></img>自己<header></header>分析class内容和src链接。

标签: pythonscrapy

解决方案


您可以使用 XPath:

response.xpath('//header')

对于图像:

response.xpath('//header//img') # This assumes there are img tags somewhere inside header

添加@class到选择器,使其返回类值和@srcsrc 值。


推荐阅读