this post was submitted on 02 Feb 2024
14 points (85.0% liked)

Python

7377 readers
29 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
 

I want to scrape a website using python selenium however every time it gives different id to same html element. I don't know how to circumvent it.

maybe XPATH is my saviour? but I don't know how reliable it is.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] bjorney@lemmy.ca 15 points 2 years ago (1 children)

You should be able to search by class name, find something salient in the Dom tree nearby and step over/up/down to your desired element

[โ€“] SatouKazuma@lemmy.world 4 points 2 years ago

Yup. CSS selectors are great for this very reason.