从 Steam 社区市场上的物品获取检查 link

Get inspect link from Item on Steam Community Market

使用下面的 link 我想为页面上的每个列出的项目找到检查 link,最好使用 Python。 https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Redline%20%28Field-Tested%29

inspect link 位于此元素的 href 中: <a class="popup_menu_item" href="steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M3278013081425287850A19320993972D11848058731724408597">Inspect in Game...</a>

我面临的问题是检查 link 只有在我们为每个列表按下此元素时才会创建和填充: <a id="listing_3278013081425287850_actionmenu_button" class="market_actionmenu_button" href="javascript:void(0)"></a>

这是我当前的代码:

import requests
from bs4 import BeautifulSoup

baseurl = "https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Redline%20%28Field-Tested%29"
site = requests.get(baseurl)
soup = BeautifulSoup(site.content, 'html.parser')
a = soup.select("#market_action_popup_itemactions > a")

但是因为 html 项目不存在,所以我找不到任何东西。 a = []

如何填充 html 项并读取它的 href 值? 我需要使用 selenium 之类的东西吗?或者这可以通过请求使用吗?

按照评论中的建议使用 selenium 使其正常工作。

baseurl = "https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Redline%20%28Field-Tested%29"
driver.get(baseurl)
btns = driver.find_elements_by_class_name("market_actionmenu_button")
for btn in btns:
    driver.execute_script("arguments[0].click();", btn)
    popup = driver.find_element_by_css_selector("#market_action_popup_itemactions > a")
    href = popup.get_attribute('href')
    print(href)