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.

  • bjorney
    link
    fedilink
    168 months ago

    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

    • @[email protected]
      link
      fedilink
      English
      58 months ago

      yup. Use the structure of the document.

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

    • 佐藤カズマ
      link
      48 months ago

      Yup. CSS selectors are great for this very reason.