我想刮股票名称,其相关的新闻和时间的消息,但scrapy不返回任何输出为什么此选择器在chrome中工作,但不在scrapy中?
class StationDetailSpider(CrawlSpider):
name = 'tone'
start_urls = ["http://www.moneycontrol.com/india/stockpricequote/auto-lcvs-hcvs/ashokleyland/AL"]
def parse_news(self, response):
for brickset in response.css:
#TIME_SELECTOR = '//div.gD_10 ::text'
NAME_SELECTOR = './/div[@class='b_42h1[@class='b_42'] PT5 PR']'
#NEWS_SELECTOR = '//a.bl_13 ::text'
yield {
#'time': brickset.css(TIME_SELECTOR).extract_first(),
#'news': brickset.css(NEWS_SELECTOR).extract_first(),
'name': brickset.xpath(NAME_SELECTOR).extract_first(),
}
任何一种洞察力将不胜感激。我尝试了其他格式,但徒劳无功。
对不起,先生,但即使这种方法不起作用,也没有输出。 –
>>> response.xpath('// div [@ class =“b_42 PT5 PR”]/h1/text()')。extract_first() u'Ashok Leyland'''' – Casper
Showed you in我的评论^,它输出我的回答 – Casper