Home > database >  I want to use Selenium to find specific text
I want to use Selenium to find specific text

Time:11-04

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('//*[@]')

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"

CodePudding user response:

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('//*[@]'))

  • Related