ddjfjfj djfiejdn
ddjfjfj djfiejdn

Reputation: 131

I want to use Selenium to find specific text

I was going to use Selenium to crawl the web

from selenium import webdriver
from selenium.webdriver.common.by import By
import time

options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome('./chromedriver', options=options)
driver.get('https://steamdb.info/tag/1742/?all')
driver.implicitly_wait(3)

li = []
games = driver.find_elements_by_xpath('//*[@class="table-products.text-center.dataTable"]')

for i in games:
    time.sleep(5)
    li.append(i.get_attribute("href"))

print(li)

After accessing the steam url that I was looking for, I tried to find something called an appid

The picture below is the HTML I'm looking for

enter image description here

I'm trying to find the number next to "data-appid="

But if I run my code, nothing is saved in the "games"

Upvotes: 0

Views: 40

Answers (1)

Rihhard
Rihhard

Reputation: 66

Correct me if I'm wrong but from what I can see this steam page requires you to log-in, are you sure that when webdriver opens the page that same data is available to you ?

Additionally when using By, the correct syntax would be games = driver.find_element(By.CSS_SELECTOR('//*[@class="table-products.text-center.dataTable"]'))

Upvotes: 1

Related Questions