user8128940
user8128940

Reputation: 39

Using ExecuteScriptAsync in Webview2 to extract data from a website

Previously I've used the .net Webbrowser class to scrape data from webpages that require you to actually load them for the relevant data to appear, making simple HTML requests useless. Since that Class is now unusable, I've switched to Webview2, and it has worked pretty well for 1 website. I've used the following function after loading the webpage and then parsed the data I'm after with some regex magic:

   String = Await ExecuteScriptAsync("document.documentElement.outerHTML")

However, now I'm trying to extract data from another website, and it seems the data I'm trying to extract is just not found in the outerHTML string at all. I know it's not an issue with the function activating before the webpage is loaded since for debugging I wait until I see the data I want on the screen and then manually activate the function with a button. Using inspect element in a regular browser I can see the data I want just fine.

I know little about website design, so maybe I'm missing something here. It was my understainding that everything visible in the webpage is represented in outerHTML. Are there other things besides outerHTML that data could be in that I could pull with ExecuteScriptAsync?

Upvotes: 1

Views: 950

Answers (0)

Related Questions