Scraping-TripAdvisor-with-Python-2020 icon indicating copy to clipboard operation
Scraping-TripAdvisor-with-Python-2020 copied to clipboard

Getting an error: "NoSuchElementException" for "things to do" scraper

Open Ema8899 opened this issue 3 years ago • 6 comments

Hello @giuseppegambino!

I was trying your code (thanks a lot for publishing it), and while the code to scrape restaurants' reviews works, the code to scrape reviews for "things to do" does not work. I get this message when I run it:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":".//div[contains(@data-test-target, 'expand-review')]"}

Would it be possible for you to fix it? It would be extremely helpful. Thanks a lot and happy 2022!

Ema8899 avatar Jan 05 '22 13:01 Ema8899

Hello @Ema8899

I took a look at the script's default site, which is this: https://www.tripadvisor.com/Hotel_Review-g60763-d1218720-Reviews-The_Standard_High_Line-New_York_City_New_York.html and the element actually exists.

Can you please link the website with which you gave the error? Because before doing some tests / debugging I would like to understand if by chance the site in question has only short reviews and therefore does not have the button to show them complete.

Happy 2022 to you too :)

giuseppegambino avatar Jan 05 '22 14:01 giuseppegambino

@giuseppegambino: thanks for your prompt reply!

Here is the link of the attraction: https://www.tripadvisor.com/Attraction_Review-g187791-d197714-Reviews-Pantheon-Rome_Lazio.html

Just to be sure, I have tried the code just now and it keeps giving me the error I mentioned above.

Thanks again for your help!

Ema8899 avatar Jan 05 '22 14:01 Ema8899

They changed again the webpages :((

I am noticing that now there is not only the difference between restaurants and everything else (which I had called things_to_do), but there is the "hotels" section, so now there are 3 (or at least those counted by me) site structures on tripadvisor: restaurants, hotels and tourist attractions.

Fortunately, but not for you, the hotel pages retain the structure of the old "things to do", instead the tourist attractions have different html / css fields .. so I have to work on it a bit ..

As soon as I have some free time, I immediately get to work! Thanks for the update @Ema8899

giuseppegambino avatar Jan 05 '22 14:01 giuseppegambino

Thank you @giuseppegambino

Have a good day!

Ema8899 avatar Jan 05 '22 14:01 Ema8899

Hi @giuseppegambino have you perhaps had a chance to update this to cater for Hotels?

glaupie avatar Apr 12 '22 19:04 glaupie

Hi @giuseppegambino I'm really excited to work with this script. I don't know if you've had time to look at the new CSS/HTML, but was wondering if there had been any updates to the 'Attractions' script. When I run it I get the following error (similar but distinct from the person above):

Message: no such element: Unable to locate element: {"method":"xpath","selector":".//div[@class='_2fxQ4TOx']"}

I was just wondering since this is for the dates element if there might be a way for me to find the xpath on the Chrome site itself by inspecting it--I tried but no luck yet. Anyway, appreciate all the hard work you've done on this, thanks so much!

spudmc10 avatar Oct 19 '22 00:10 spudmc10