如何解决如何使用 Scrapy 框架解析文本中的 href 属性?应该写入哪个 xpath 值来捕获它?
我正在尝试使用 Scrapy 框架解析 RSS 提要。我正在使用 xmlfeedspider(scrapy) 解析并将其保存为 json 文件。我的函数正在工作,除了获取 src 属性中的图像 url 地址。 我需要更正 xpath 值以解析 src arttribute 下的文本。
我的 xpath 是“//item/description/@src”,它不起作用。我知道描述下的所有值都是文本格式。请告诉我如何从文本中获取 src 值。
Rss link :http://feeds.feedburner.com/daily-express-news-showbiz
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>
<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>
<rss
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>Daily Express :: News Feed</title>
<link>http://www.express.co.uk</link>
<description>Simply The Best 7 Days A Week</description>
<language>en-gb</language>
<image>
<link>http://www.express.co.uk</link>
<url>https://cdn.images.express.co.uk/img/logorss.gif</url>
<title>Daily Express</title>
</image>
<pubDate>Sun,04 Jul 2021 04:55:29 +0100</pubDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>CakePHP</generator>
<managingEditor>news@express.co.uk</managingEditor>
<webMaster>news@express.co.uk</webMaster>
<atom10:link
xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/daily-express-news-showbiz" />
<feedburner:info uri="daily-express-news-showbiz" />
<atom10:link
xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
<item>
<title>
<![CDATA[Dancing Prince! Charles shares which song gave him an ‘irresistible urge' to boogie]]>
</title>
<link>http://feedproxy.google.com/~r/daily-express-news-showbiz/~3/S43CDAz5nlM/prince-charles-songs-hospital-association-radio-programme-urge-dance-ont</link>
<description><a href="https://www.express.co.uk/news/royal/1458059/prince-charles-songs-hospital-association-radio-programme-urge-dance-ont"><img src="https://cdn.images.express.co.uk/img/dynamic/106/590x/1458059_1.jpg"/></a><br /><br />PRINCE CHARLES has shared a number of his favourite songs,one of which gave him an "irresistible urge to get up and dance".<**img src="http://feeds.feedburner.com/~r/daily-express-news-showbiz/~4/S43CDAz5nlM**" height="1" width="1" alt=""/></description>
<comments>https://www.express.co.uk/news/royal/1458059/prince-charles-songs-hospital-association-radio-programme-urge-dance-ont#comments</comments>
<pubDate>Sun,04 Jul 2021 04:47:52 +0100</pubDate>
<guid isPermaLink="false">https://www.express.co.uk/news/royal/1458059/prince-charles-songs-hospital-association-radio-programme-urge-dance-ont</guid>
<feedburner:origLink>https://www.express.co.uk/news/royal/1458059/prince-charles-songs-hospital-association-radio-programme-urge-dance-ont</feedburner:origLink>
</item>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。