'Whats is the correct element type for this selenium project?
I'm trying to find something out but nothing works. I'm trying to use a web scraper, to print all of the hot deal percentages on this website: ' https://shadowpay.com/en?price_from=0.00&price_to=34.00&game=csgo&hot_deal=true ' But I ran into an error (I have tried many ways to go about this, but I think that it's my lack of HTML) The error is that the element that I want to print ('percent-hot-deal__block'), isn't a class name, but I've tried a lot of find_element_by options, nothing worked, so I'm coming here. Code:
import pandas as pd
from bs4 import BeautifulSoup as bs
from selenium import webdriver
import requests
import time
#
perc = []
#
PATH = 'C:/Users/<user__name>/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()
Please help, if I need to edit anything, be sure to comment. Also, I know that importin so many things is useless, I was following other tutorials on the same file.
Solution 1:[1]
Try this:
import json
import requests
r = requests.get('https://api.shadowpay.com/api/market/get_items?types=[]&exteriors=[]&rarities=[]&collections=[]&item_subcategories=[]&float={"from":0,"to":1}&price_from=0.00&price_to=34.00&game=csgo&hot_deal=true&stickers=[]&count_stickers=[]&short_name=&search=&stack=false&sort=desc&sort_column=price_rate&limit=50&offset=0')
for i in range(len(r.json()["items"])):
try:
print(r.json()["items"][i]["collection"]["name"], ",", r.json()["items"][i]["discount"])
except Exception as err:
print(err)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dimay |
