Web Page Retriever + XPath . . .

Hi all,

I’m struggling a bit with XPath . . . from a page from Marketscreener I want to copy the Sector (see screenshot). First I thought it was a iFrame-problem but in my opinion it isn’t.

I receive some fault data and not the expected sector-data.

Does anyone have an idea to get this data?

Many THNX in advance

marketscreener_boeing_20230724.knwf (7.6 KB)

Hey @sanderlenselink,
If you want to receive all the subsections you need to configure the output type of the XPath to be either a collection or to be multiple rows. I also used the following XPath:

/html/body/div[1]/div/div/main/div[4]/div[2]/div[1]/div[2]/table/tbody/*

Best,
Alex

1 Like

Hello @AlexKlos,

thnx for your super fast feedback. This works for me !!!

Normally within XPath I in the Configure window I select in the code the relevant item.
Marketscreener changed some webpages.

I suppose the “trick” is in the first “div[1]” ???

Is there a tool to detect the right item? Because your string “/html/body/div[1]/div/div/main/div[4]/div[2]/div[1]/div[2]/table/tbody/*” means a lot of puzzling?

Regards,
-Sander

Hey @Alex_JW,

yep . . . the story is that I tried earlier what you recommend (right click / inspect etc). However, maybe I made a mistake or typo because it resulted in all empty cells.

Now I tried it once again and . . . . hurrah !!!

I played with XPather . . . that’s a great utility and makes life much easier :ok_hand: :ok_hand: :ok_hand:

This helps me indeed

-Sander

1 Like

Sorry, i deleted my post by accident… :

Hey @sanderlenselink ,
good question and yes there is a trick to it. I do it like this:

  • Go to the webpage with the item
  • Right click on the element and ‘inspect’
  • In the HTML, rightclick the element again and ‘copy XPath’

Now you have the XPath for this one element. If you want to receive multiple elements with one XPath i recommend using a online XPath verification tool (like XPather) where you can start with the previously obtained HTML and XPath for the first element and alter it on order to get all the elements you need.

Keep in mind, that XPaths are vulnerable to page changes. If the provider of the webpage changes one element in the path, the query will break with absolute paths.

I hope this answer helps,
Alex

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.