Search code examples
powershellwindows-server-2012data-extraction

Extracting data from website's table


I would like to extract data automatically every 10 minutes from website's table and save it to .csv format.

My initial thought was to use "iMacro for Chrome" extension to retrieve data, but Windows Task Scheduler is unable to open Chrome and run the .iim macro automatically.

My next thought was to use PowerShell's Invoke-WebRequest to retrieve the data, but it only fetches a part of it.

(Invoke-WebRequest "<url>").content


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge, chrome=1">  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        
</head>
<body>
<SCRIPT language="JavaScript">top.location = '/index.php?PHPSESSID=1ocektpk6itt46r08lq7epln32&internalurltime=1511187487&logout=1'</SCRIPT></body></html>

Log-in uses SSO.

So, my question would be following: are there any more ways to retrieve data automatically every 10 minutes, without installing 3rd-party software?

Thank you!


Solution

  • You could also try these:

    Invoke-RESTMethod -URI "http://www.example.com" -Method Get

    $webClient = [System.Net.Webclient]::new() $webClient.DownloadString() or .DownloadFile() deending on what you're after