1
votes

ImportXML : I am trying to scrape http://www.tripadvisor.in/Hotels-g297615-c2-Gurgaon_Haryana-Hotels.html . I need the following fields - Name of the hotel, URL, Address, City, Pincode, no of reviews(just number) for each hotel, percentage and amenities. I want this all in a single row for a single hotel. Can anyone help me out.

Google Doc Link: https://docs.google.com/spreadsheets/d/1D6X9c9uX7AltxWQ3ln0Pqqzq_CIroCkDxPYr6lv-47k/edit#gid=1666841843

I am unable to get all the above requirements in GoogleDoc. I am stuck in the address scraping just beside the URL.

1
I have extracted all the 263 hotel names and their respective URLs. For extracting the address, i have used this code : =IMPORTXML(concatenate("tripadvisor.in",D2),"//…) This is giving me same address twice for a cell(url). This is because there are two same address in the page that refers to the query given. Now i just want one address. How do i go about about doing this? - user3398251

1 Answers

0
votes

Responding to your comment, you can limit data returned by the xpath to one using index ([1]), for example (formatted for readability):

=IMPORTXML(concatenate("http://www.tripadvisor.in",D2),
            "(//span[@class='street-address'])[1]")