我在想办法,但什么都没用。 我正在尝试使用网络刮板,在该网站上打印所有热门交易百分比: “https://shadowpay.com/en?price_from=0.00&price_to=34.00&game=csgo&hot_deal=true” 但是我遇到了一个错误(我已经尝试了很多方法来解决这个问题,但我认为这是因为我缺乏HTML) 错误是我想要打印的元素(“percent-hot-deal\uuu block”)不是类名,但我已经尝试了很多按选项查找元素的方法,但都没有效果,所以我来这里。 代码:
import pandas as pd
from bs4 import BeautifulSoup as bs
from selenium import webdriver
import requests
import time
#
perc = []
#
PATH = 'C:/Users/Matiss/Documents/chromedriver_win32/chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.get("https://shadowpay.com/en?price_from=0.00&price_to=34.00&game=csgo&hot_deal=true")
#
dealblock = driver.find_elements_by_tag_name("span")
for deal in dealblock:
header = deal.find_element_by_class_name("percent-hot-deal__block")
print(header.text)
#
time.sleep(15)
driver.quit()
请帮助,如果我需要编辑任何内容,请务必发表评论。 另外,我知道导入这么多东西是没有用的,我在同一个文件上遵循其他教程
基本上,您需要等待页面加载并获取元素
你可以这样做
更理想的方法是:
进口
试试这个:
相关问题 更多 >
编程相关推荐