Get hotel name from OTA web page Xpath

Asked 1 years ago, Updated 1 years ago, 129 views

I'd like to get the hotel name in Xpath from the OTA web page.

//*[@id="property-critical-root"]/div/div[3]/div[2]/div[2]/div[2]/div[2]/div[1]/h1

I'm at a loss because I don't know how to describe it after .

URL
https://www.agoda.com/ja-jp/imperial-hotel-osaka/hotel/osaka-jp.html?checkIn=2020-04-10&los=1&adults=1&cid=1829967&tag=380516ea-8641-a76e-6bc5-dbf155bef959&searchrequestid=932325935-4823516ea-dbf155bf959&searchrequestid=9-48-239-4825935-48-2323-2323-23235.

This is the OTA(Agoda) facility page

web-scraping xpath

2022-09-29 21:25

1 Answers

Pass the node set to string() to make the XPath evaluation result a string.If the node set is an element, it is a concatenation of the descendant text of the element.

 string (//*[@id abbreviation/h1)

By the way, if you look at the site briefly, the following simple formula seems to be fine.

string (//h1[@data-selenium="hotel-header-name"])


2022-09-29 21:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.