我已经看过了Scrapy的例子,它们很有意义,但是当我在新闻提要上试用它时,我只得到标题,也不知道如何继续下去。
scrapy shell http://feeds.bbci.co.uk/news/rss.xml我能从这里得到的只有
response.xpath('//title')哪种输出
<Selector xpath='//title' data=u'<title xmlns:media="http://search.yahoo.'>]我怎样才能找到里面的标签?
当我尝试这个:
response.xpath('//div')它返回null。我试过检查来自Chome的元素来检查内容,但是我甚至无法到达身体去尝试一些东西。谢谢
发布于 2015-01-10 14:42:53
rss不是html文档,而是xml文档。您可以在rss的rss.asp上找到相关信息。rss文档看起来类似于:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>W3Schools Home Page</title>
<link>http://www.w3schools.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS Tutorial</title>
<link>http://www.w3schools.com/rss</link>
<description>New RSS tutorial on W3Schools</description>
</item>
<item>
<title>XML Tutorial</title>
<link>http://www.w3schools.com/xml</link>
<description>New XML tutorial on W3Schools</description>
</item>
</channel>
</rss>所以它中没有div标记。要获取每个帖子/新闻的描述,可以使用response.xpath('//description/text()')
刮伤的文档可以在这里找到,http://doc.scrapy.org/en/latest/intro/tutorial.html
https://stackoverflow.com/questions/27876936
复制相似问题