Can we scrape website which gives random id's every time to HTML tag?
from kionite231@lemmy.ca to python@programming.dev on 02 Feb 2024 11:53
https://lemmy.ca/post/14561441

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.

#python

threaded - newest

bjorney@lemmy.ca on 02 Feb 2024 12:28 collapse

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

sbv@sh.itjust.works on 02 Feb 2024 12:40 next collapse

yup. Use the structure of the document.

If that isn’t possible, use the visual representation.

SatouKazuma@lemmy.world on 02 Feb 2024 12:57 collapse

Yup. CSS selectors are great for this very reason.