0
votes

First of all, I'm completely incompetent and my hours-long attempts at trying to make this work have been fruitless. So, please, there's someone that can help me.

I have

table id="..........." tablesorter class="........"

They are in the same line of code ad I'm able to scrape until the first element. For me it's important to scrape by the second one. I'm tryng different way but nothing

investing

In the image, in the part highlighted on the left where there is the drop-down menu, it's possible to select the different American markets (Nasdaq, DowJones, S&P500 etc.). When I select a market other than DowJones, the URL of the page always remains the same, while the part that I highlighted on the right changes (tablesorter class = "............"). In my sheet, I've done this but it can't allow me to scrape different market (only the default table thay you see when open the webpage)

spreadsheet

1
share a copy of your sheet with example of desired result - player0
When you change the selected market, it makes a silent call (without changing the URL) to it.investing.com/equities/… - the last part, index_id, corresponds to the id attribute in the HTML option element, so 20 is Nasdaq 100, for example. That URL returns what looks to me like the HTML table without the styles, which it then probably embeds in the page, but you may be able to scrape the response directly. You can look at the network tab in Chrome's developer tools to see which URLs are being called behind the scenes. - Bets

1 Answers

0
votes

Your main problem is that IMPORTXML can only retrieve information from static content in websites. Therefore, any content inserted dynamically can't be retrieved by this function.

In your case, you can check what content is not static by heading over to the website https://it.investing.com/equities/americas and then disabling JavaScript on it. To do so if you are using Chrome please follow this guide.

As Javascript will add dynamic content to the site, when you disable it you will observe that the information subject to change with the dropdown doesn't actually change which means that it was dynamically inserted and therefore can't be accessed by IMPORTXML. I have attached an image below showing this.

As a workaround to this you will need to use other web scraping techniques.

enter image description here