
我想获得每个页面的关键字列表,然后我可以将其存储在数据库中.这就是我到目前为止所拥有的.
scrapy shell http://news.nationalgeographic.com/2015/03/150318-pitcairn-marine-reserve-protected-area-ocean-conservation/>>> response.xpath('//Title/text()').extract()[u'World\u2019s Largest Single Marine Reserve Created in Pacific']>>> response.xpath("//Meta[@name='keywords']")[0].extract()u'<Meta name="keywords" content="提取,关键字">' 我想做的只是从Meta标签中提取内容,其中name =’keywords’
谢谢!
解决方法 只需添加/ @ content即可提取内容属性:response.xpath("//Meta[@name='keywords']/@content")[0].extract() 总结 以上是内存溢出为你收集整理的xpath – 使用scrapy从metatag中提取关键字全部内容,希望文章能够帮你解决xpath – 使用scrapy从metatag中提取关键字所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)