此问题在此处已有答案:
Can scrapy be used to scrape dynamic content from websites that are using AJAX?(9个答案)
6个月前关闭。
我试着从网站www.example.com上刮出结果https://howlongtobeat.com/#search。然而,当我刮的时候,20个结果中只有前6个结果。
我的代码:
import scrapy
cards = response.css('div[class="search_list_details"]')
for card in cards:
game_name = card.css('a[class=text_white]::attr(title)').get()
print(game_name)
输出:
'Elden Ring'
'Cyberpunk 2077'
'Kirby and the Forgotten Land'
'LEGO Star Wars The Skywalker Saga'
'Tomb Raider'
'Hollow Knight'
'Eiyuden Chronicle Rising' #This is not displayed on the page
'This War of Mine' #This is also not displayed on the page
我尝试使用其他选择器的卡,如response.css('li[class=back_darkish]')
,但无济于事。
此外,我如何得到其他数据,如小时跳动,使我得到一个法令的名称,类型的完成和小时?:
<div>
<div class="search_list_tidbit text_white shadow_text">Main Story</div>
<div class="search_list_tidbit center time_100">50½ Hours </div>
<div class="search_list_tidbit text_white shadow_text">Main + Extra</div>
<div class="search_list_tidbit center time_100">94 Hours </div>
<div class="search_list_tidbit text_white shadow_text">Completionist</div>
<div class="search_list_tidbit center time_100">127 Hours </div>
</div>
1条答案
按热度按时间vd2z7a6w1#
实际上,数据是从外部url生成的,这是API调用HTML响应作为
POST
方法。输出: