提问人:user11225404 提问时间:7/4/2022 最后编辑:user11225404 更新时间:7/5/2022 访问量:98
我想获得 Steammarket 中的最低价格
I want to get the lowest price in steammarket
问:
[在此输入图片描述][1] 我写了这个可怕的解析器来获得永久的售价。
我在 Pycharm 中以正常模式运行它,但它打印“无”。 但是在调试模式下,它会返回永久销售价格。
import time
from selenium.webdriver.common.by import By
from selenium import webdriver
def permanent_sale_price(name: str):
url = "".join(("https://steamcommunity.com/market/listings/730/", name))
PATH = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedgedriver.exe"
driver = webdriver.Edge(PATH)
driver.get(url)
items = driver.find_elements(By.ID, "market_commodity_buyrequests")
tx = item.text.split(" ")
price = float(tx[-1][1:])
return price
def main():
name = "P250 | Franklin (Field-Tested)"
print(permanent_sale_price(name))
if __name__ == '__main__':
main()
“[1]:https://i.stack.imgur.com/Est2D.png 永久售价,html中的id”market_commodity_buyrequests“”
(P.S.没有循环)
答:
0赞
federikowsky
7/5/2022
#1
试试这个
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def permanent_sale_price(name: str):
url = "".join(("https://steamcommunity.com/market/listings/730/", name))
PATH = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedgedriver.exe"
driver = webdriver.Edge(PATH)
driver.get(url)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "market_commodity_buyrequests"))
)
items = driver.find_elements(By.ID, "market_commodity_buyrequests")
tx = item.text.split(" ")
price = float(tx[-1][1:])
return price
def main():
name = "P250 | Franklin (Field-Tested)"
print(permanent_sale_price(name))
if __name__ == '__main__':
main()
上一个:“请求购买”价格Steam
评论