Home > database >  Trouble finding a element on myanimelist.net using selenium package in python
Trouble finding a element on myanimelist.net using selenium package in python

Time:11-09

trying to get the ones that are add and not the ones that are CW

the ctrl shift i of the add button

this one is the ctrl shift i of the CW button

I am having problems where nothing is coming up no matter what I do I have tried the class, the title, partial link text(they each have their own id to identify witch anime) and they all turn up blank or invalid.

The current webpage is https://myanimelist.net/anime.php?letter=N&show=400.

I am trying to get a script in python using selenium that will find all of the elements on the page that still need to be added to my watch list and then if they still do I have a second part of script that will open up the anime and add it to my list.

CodePudding user response:

xpath is the best way to select elements in pages for beginners

Where more than one result column is sorted on top of a table (tbody) like on this page, I suggest you select the table first and proceed from the table to the inner layers.

xpath path that selects the element of the href with each link:

//tbody/tr/td[2]/div/a[@class='hoverinfo_trigger fw-b fl-l']

To print the link of each anime:

animeList = driver.find_elements(By.XPATH, "//tbody/tr/td[2]/div/a[@class='hoverinfo_trigger fw-b fl-l']")
for anime in animeList:
    print(anime.get_attribute("href"))
  • Related