oemript Posted June 26, 2019 Posted June 26, 2019 (edited) Referring to following link and image, I would like to know on how to click "Export" and save file into "C:\folder\abc.csv" using PowerShell Script. Does anyone have any suggestions? Thanks in advance for any suggestions https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal Edited June 26, 2019 by oemript
Exit Posted June 26, 2019 Posted June 26, 2019 and again ... Quote And what have you tried so far? Show us your script. App: Au3toCmd UDF: _SingleScript()
Moderators JLogan3o13 Posted June 26, 2019 Moderators Posted June 26, 2019 PowerShell's usage when dealing with websites is not that different than AutoIt. This is just a rough example I used for another site, but should get you started: $username='username' $password='password' $ie = New-Object -ComObject 'internetExplorer.Application' $ie.Visible= $true $ie.Navigate("site-name") while ($ie.Busy -eq $true){Start-Sleep -seconds 1;} $usernamefield = $ie.Document.getElementByID('UserName1') $usernamefield.value = $username $passwordfield = $ie.Document.getElementByID('Passwd1') $passwordfield.value = $password $Link=$ie.Document.getElementsByTagName("input") | where-object {$_.className -eq "continue"} $Link.click() "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
oemript Posted June 26, 2019 Author Posted June 26, 2019 Referring to following coding, I would like to know on how to click Export Button and Download csv file using PowerShell Script. # Download the Excel file $clnt = new-object System.Net.WebClient $url = "https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal" $file = "C:\folder\abc.csv" try { $request = [System.Net.WebRequest]::Create($url) $request.Method = 'HEAD' $response = $request.GetResponse() $httpStatus = $response.StatusCode $urlIsValid = ($httpStatus -eq 'OK') $tryError = $null $response.Close() ???? How to click Export Button and Download csv file ??? $clnt.DownloadFile($url,$file) } catch [System.Exception] { $httpStatus = $null $tryError = $_.Exception $urlIsValid = $false; Write-Host "There was an error downloading $file" $j++ } Do you have any suggestions? Thank you very much for any suggestions (^v^)
Moderators JLogan3o13 Posted June 26, 2019 Moderators Posted June 26, 2019 Can you pull the button element off the page? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
oemript Posted June 26, 2019 Author Posted June 26, 2019 14 minutes ago, JLogan3o13 said: $Link=$ie.Document.getElementsByTagName("input") | where-object {$_.className -eq "continue"} $Link.click() Referring to following html coding, I would like to know on how to apply $ie.Document.getElementsByTagName in this situation. <div class="export_list_financials"> <div class="list_select"> <li id="Li2" class="r_dd1" onclick="showDropdown1(event,this);"> <a class="r_ddh1" id="orderType">Ascending</a><ul style="display: none;"><li> <a href="javascript:orderChange('asc','Ascending');">Ascending</a></li><li> <a href="javascript:orderChange('desc','Descending');">Descending</a></li></ul></li></div> <a class="large_button" href="javascript:exportKeyStat2CSV();"> <span class="csv"></span> <div>Export</div></a></div> Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^)
oemript Posted June 26, 2019 Author Posted June 26, 2019 (edited) Referring to following image, I get error and would like to know on what object should be selected before click # Download the Excel file $clnt = new-object System.Net.WebClient [Net.ServicePointManager]::SecurityProtocol = 'Tls12' $url = "https://financials.morningstar.com/ratios/r.html?t=0P0001648D&culture=en&platform=sal" $request = [System.Net.WebRequest]::Create($url) $request.Method = 'HEAD' $response = $request.GetResponse() $httpStatus = $response.StatusCode $urlIsValid = ($httpStatus -eq 'OK') $tryError = $null $response.Close() $Link=$ie.Document.getElementsByTagName("large_button") $Link.click() Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited June 26, 2019 by oemript
oemript Posted June 27, 2019 Author Posted June 27, 2019 Referring to following html coding, does it require AJax in order to perform download task? Can PowerShell able to execute this event for downloading file? or this is the limitation of PowerShell, because it is not support AJax components. <div class="export_list_financials"> <div class="list_select"> <li id="Li2" class="r_dd1" onclick="showDropdown1(event,this);"> <a class="r_ddh1" id="orderType">Ascending</a><ul style="display: none;"><li> <a href="javascript:orderChange('asc','Ascending');">Ascending</a></li><li> <a href="javascript:orderChange('desc','Descending');">Descending</a></li></ul></li></div> <a class="large_button" href="javascript:exportKeyStat2CSV();"> <span class="csv"></span> <div>Export</div></a></div> Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^)
oemript Posted June 27, 2019 Author Posted June 27, 2019 Does anyone have any suggestions on whether PowerShell can execute this event for downloading file or PowerShell is not support AJax components? Thanks, to everyone very much for any suggestions (^v^)
Moderators JLogan3o13 Posted June 28, 2019 Moderators Posted June 28, 2019 @oemript you have been around long enough to know better than to bump your posts in less than 24 hours. Just because this is the most important thing in the world to you does not mean it is to everyone else. And, as usual, if you're not getting the answers you seek perhaps you're not providing enough information or, as is usually the issue with you, not showing enough of what you have tried on your own. If you are going to continue to sit around and wait for someone to spoon-feed it to you, at least wait 24 hours before bumping and bothering everyone. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now