【发布时间】:2021-04-28 06:54:46
【问题描述】:
我试图找出一些东西,但没有任何效果。 我正在尝试使用网络抓取工具来打印此网站上的所有热卖百分比: 'https://shadowpay.com/en?price_from=0.00&price_to=34.00&game=csgo&hot_deal=true' 但是我遇到了一个错误(我已经尝试了很多方法来解决这个问题,但我认为这是我缺乏 HTML) 错误是我要打印的元素('percent-hot-deal__block')不是类名,但我尝试了很多 find_element_by 选项,没有任何效果,所以我来这里。 代码:
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()
请帮忙,如果我需要编辑任何内容,请务必发表评论。 另外,我知道导入这么多东西是没用的,我在同一个文件上关注其他教程。
【问题讨论】:
标签: python html css selenium web-scraping