1

I would like to print text from webpage https://cicero.blazni.cz/lipsum.php . This page generates words when its loaded. It works fine if the page is loaded in browser, powershell prints the sentence which is changed every 5s. If I close browser, the page is not loaded and invoke-request get just the last sentence loaded.

Is there the way to "run" php and than download information? Or another way to get different result everytime I run my code?

$page  = Invoke-WebRequest -Uri https://cicero.blazni.cz/lipsum.php
$reading = $page.parsedhtml.getElementById("rightcol").firstChild.innerhtml
$reading

I hope my question is understandable. Thank you for your time.

Lucie
  • 185
  • 10
  • 1
    It is not obvious what you are trying to, please explain it further. Is your powershell script on a different machine to the php code ? – Rohit Gupta Oct 12 '22 at 22:09
  • @RohitGupta There is the webpage, which generates random sentences (every 5s). I would like to get fresh new sentence using powershell if I invoke webrequest to webpage. It works, if the browser with page is open, powershell code get new sentence via my code. But if I close the browser, somehow I get just the last printed sentence. How to make my code work even when browser is closed? – Lucie Oct 14 '22 at 23:03

1 Answers1

0

Powershell cmdlets are .NET code that don't exist in the filesystem. Execution is passed to the application - in this case the browser.

A PowerShell cmdlet is a lightweight command that is used in the Windows PowerShell environment.

The public properties that define the parameters that are available to the user or to the application that is running the cmdlet.

PowerShell Module Cmdlets and Commands

I am piecing this together so I can't give you all the references.

The step-by-step process is here to stop this, I don't want to plagiarize it. How to use Invoke-WebRequest in PowerShell without having to first open Internet Explorer

Disclaimer, I have no affiliation with this site.

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
  • Wow. There is whole new world in this information! Before I will try the code, I checked if the webpage runs on IE - and it doesnt. Will it affect solution? – Lucie Oct 15 '22 at 08:31
  • And also: it seems that "Set-ItemProperty ..... -Value 1" means just: load the homepage straight away, what does it mean for my link? info from here: https://admx.help/?Category=Windows_7_2008R2&Policy=Microsoft.Policies.InternetExplorer::NoFirstRunCustomise_1 – Lucie Oct 15 '22 at 08:32