how to by pass license agreement while downloading from any site

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Ankit Parmar Ankit Parmar 10 months, 1 week ago.

  • Author
    Posts
  • #34364
    Profile photo of Ankit Parmar
    Ankit Parmar
    Participant

    Hi,

    I am downloading one file extension (.tgz) from splunk website which has a license agreement so in order to download the file first you have to login splunk and then it shows the page of license agreement and when you accept it then file will be visible for downloading. I have made one script in which it is successfully logged in the splunk account and downloading the file but not fully. The file size is around 104 kb but it is downloading 44.7kb so anybody can help me please in order to complete this task? Here is my code –

    $postParams = @{username='username';password='password'}
    Invoke-WebRequest -Uri https://login.splunk.com/index.php?module=roles
    -Method POST -Body $postParams
    $url = "https://splunkbase.splunk.com/app/1586/release/1.0.2/agree/"
    $downloadpath = "C:\Users\ankitpar\Downloads\splunk-addon-for-microsoft-azure_102.tgz"
    Invoke-WebRequest -Uri $url -OutFile $downloadpath

    if you will run above given script upto the second line so it shows in output of powershell that HTTP response 200 OK connection keep-alive which means i have successfully logged in.

    Thanks in advance
    Ankit

  • #34375
    Profile photo of Don Jones
    Don Jones
    Keymaster

    This is probably something you should take to Splunk. Honestly, without digging into the very specifics of their web site – which isn't really a PowerShell question – there's no way to answer the question.

  • #34416
    Profile photo of Ankit Parmar
    Ankit Parmar
    Participant

    Thanks for your output.. thinking the same ..

  • #34423
    Profile photo of Ankit Parmar
    Ankit Parmar
    Participant

    Hi Don,

    Finally it works.. made it..

    $username = "username"
    $password = "password"
    $ie = New-Object -com InternetExplorer.Application
    $ie.visible=$True
    $ie.navigate("https://login.splunk.com/index.php?module=roles&func=showloginform")
    while($ie.ReadyState -ne 4) {start-sleep -Seconds 5}
    $ie.document.getElementById("username").value= "$username"
    $ie.document.getElementById("pass").value = "$password"
    $ie.Document.getElementById('login').click()
    $ie.visible=$false
    $ienew = New-Object -com InternetExplorer.Application
    $ienew.visible=$True
    $ienew.navigate("https://splunkbase.splunk.com/app/1586/release/1.0.2/agree/")
    while($ienew.ReadyState -ne 4) {start-sleep -Seconds 5}
    $ienew.document.getElementsByTagName("input").item(1).click()
    $ienew.document.getElementsByTagName("button").item(0).click()

    Thanks
    Ankit

You must be logged in to reply to this topic.