我试着在这个网址上刮些东西:
"https://www.bloomberg.com/news/articles/2019-05-30/tesla-dealt-another-blow-as-barclays-sees-it-as-niche-carmaker"我只想得到标题和日期发布,任何你能给我的样例代码,甚至飞溅等等。
到目前为止我尝试的是
def parse(self, response):
yield scrapy.Request('https://www.bloomberg.com/news/articles/2019-05-30/tesla-dealt-another-blow-as-barclays-sees-it-as-niche-carmaker -H x-crawlera-use-https:1',
headers={'X-Crawlera-Session': create,
'X-Crawlera-Timeout': 40000,
'X-Crawlera-Max-Retries': 5,
'X-Crawlera-Cookies': disable,
'X-Crawlera-Session': self.session_id
},
callback=self.parse_sub,
)
def parse_sub(self, response):
response.xpath("//h1[@class = 'lede-text-v2__hed']").extract_first()
response.xpath("//meta[@property = 'og:title']/@content").extract_first()
response.xpath("//time[@class = 'article-timestamp']/@datetime").extract_first()
print(response.text)我也使用爬虫,但它一直在探测我作为一个机器人。
发布于 2019-06-11 07:22:42
仅用硒来提取标题--当巴克莱称其为“利基汽车制造商”和发布日期(即2019年5月30日,5:26 PM GMT+5:30 )时,特斯拉( Tesla )又受到了打击,你必须为visibility_of_element_located()诱导WebDriverWait,你可以使用以下解决方案:
https://stackoverflow.com/questions/56537590
复制相似问题