Python 如何使用scrapy解析xml

Python 如何使用scrapy解析xml,python,xml,web-scraping,scrapy,Python,Xml,Web Scraping,Scrapy,如何使用scrapy刮取XML 我的XML如下所示: <rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0"> <channel> <generator>NFE/5.0</generator> <title>"python" - Google News</title> <link> https:/

如何使用scrapy刮取XML

我的XML如下所示:

    <rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
    <generator>NFE/5.0</generator>
    <title>"python" - Google News</title>
    <link>
    https://news.google.com/search?q=python&hl=en-IN&gl=IN&ceid=IN:en
    </link>
    <language>en-IN</language>
    <webMaster>news-webmaster@google.com</webMaster>
    <copyright>2019 Google Inc.</copyright>
    <lastBuildDate>Thu, 07 Mar 2019 16:48:55 GMT</lastBuildDate>
    <description>Google News</description>
    <item>
    <title>
    Brown snake attacks python eating a rat - NEWS.com.au
    </title>
    </channel>
    </rss>
from scrapy.spiders import XMLFeedSpider
from scrapy.http import HtmlResponse
from scrapy.selector import Selector


response = HtmlResponse(url='https://news.google.com/rss/search?q=python&hl=en-IN&gl=IN&ceid=IN:en')
xxs = Selector(response)
obj = xxs.xpath('//title/text()').extract()
我想获取标题标签中的文本。但现在我得到的是一张空名单。请帮帮我。这很重要。 非常感谢

你被robots.txt禁止了。 您需要在settings.py中更改此行为,并将ROBOTSTXT_OBEY=Trueto ROBOTSTXT_OBEY=False。

您将被robots.txt禁止。 您需要在settings.py中更改此行为,并将ROBOTSTXT_OBEY=true更改为ROBOTSTXT_OBEY=False