skip to Main Content

I used to scrape some data from a website onto a google sheet using importhtml(URL, "table", INDEX). But recently, website changed from displaying the data in a table, to displaying it as a class = card element. Is there still some way to import the data from that card to a google sheet? Perhaps with a script?

Concrete example: using =IMPORTHTML("https://www.marketscreener.com/quote/stock/APPLE-INC-4849/consensus/","table",0) in a google sheets cell would import a table with Analysts’ consensus data, but no it does not work any more.

2

Answers


  1. For this issue, you should come up with some script that will scrap your data on whether the website pattern changes or not.

    1. You can have some exemplary scripts to have a look at how to write your own script.

    2. This will also be helpful for you.

    After finalizing the script add that in your Google Sheets Extensions where you find App scripts edit them like replacing your code with the present one. Save your script and start running it. It will work perfectly.

    Login or Signup to reply.
  2. Here’s one approach you may test out:

    =let(Σ,importxml(A1,"//*[@id='consensusdetail']/div[2]"),
         Λ,regexreplace(Σ,"(Sell|Mean consensus|Number of Analysts|Last Close Price|Average target price|Spread / Average Target|High Price Target|Spread / Highest target|Low Price Target|Spread / Lowest Target)","|$1🐠"),
         index(split(tocol(split(Λ,"|")),"🐠")))
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search