Selenium请求工作,但不使用scrapy-selenium。页面加载,我从网站得到一个200的响应,但我没有得到错误,因为它没有产生任何输出。
class SeamdbTestSpider(scrapy.Spider):
name = 'steam_db_test'
start_urls = ['https://steamdb.info/graph/']
def start_requests(self):
for link in self.start_urls:
yield SeleniumRequest(
url=link,
wait_time= 10,
callback=self.parse)
def parse(self, response):
driver = response.meta['driver']
initial_page = driver.page_source
r = Selector(text=initial_page)
table = r.xpath('//*[@id="table-apps"]/tbody')
rows = table.css('tr[class= "app"]')[0:2]
for element in rows:
info_link = "https://steamdb.info" + element.css('::attr(href)').get()
name = element.css('a ::text').get()
yield {"Name": name, "Link": info_link}
1条答案
按热度按时间kgqe7b3p1#
实际上,SeleniumRequest与Scrappy并不总是完美的。同样的selement选择是Workking selenium 与bs 4,但得到空输出像你沿着与Scrappy。
Scrapy-SeleniumRequest不工作
selenium 与bs 4是工作正常:
输出:
...等等