从标签之间刮取url

2024-04-24 18:41:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个关于刮痧的问题。据我所知,链接提取器只抓取具有href=等属性的链接。我唯一遇到的问题是抓取这样的链接:<link> link here </link>这里是我的爬行蜘蛛当前使用的规则之一:Rule(LinkExtractor(allow=('feedproxy'), tags='link'), follow=True, callback="parse_urls")任何帮助都将不胜感激,谢谢。-山姆


Tags: true属性here链接规则callbacktagslink
1条回答
网友
1楼 · 发布于 2024-04-24 18:41:01

我想你需要手动处理这些链接。Link Extractors可以通过^{} and ^{} arguments控制:

tags (str or list) – a tag or a list of tags to consider when extracting links. Defaults to ('a', 'area').

attrs (list) – an attribute or list of attributes which should be considered when looking for links to extract (only for those tags specified in the tags parameter). Defaults to ('href',)

但是,它们只能从属性获取链接。你知道吗

因此,在当前配置中,只能提取以下类型的链接:

<link href="http://google.com">test</link>

相关问题 更多 >