Jump to content

Trying to save the output of a website result into text file


Recommended Posts

Hi,

I wanted to know how to extract the data from the output page which gets a different URL after submitting the form in a website. below is the code that i am using, the highlighted in GREEN is the url where i submit the form by clicking load button after that the output is shown in different url highlighted in RED, i dont know how to retain the control to that output page and save the data in text file. Any help highly appreciated.

 

#include <IE.au3>
#include <Date.au3>
#include <INet.au3>


$oIE = _IEAttach("Welcome", "Title")    
If @error == 7 Then ;If no window is found...

    $oIE = _IECreate("http://www.hajcommittee.in/") 
EndIf

_IELoadWait($oIE, 500)  ;Wait for the page to finish loading.

$oForm = _IEGetObjById($oIE, "form1")  
$oLogin = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$txtCoverNo") 
_IEFormElementSetValue($oLogin, "TNF-753-4-0")
$oButton=_IEGetObjById($oIE,"ContentPlaceHolder1_btnCoverInquiry")
_IEAction ($oButton, "click")


$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, _INetGetSource("http://www.hajcommittee.in/cover_inquiry.aspx"))
;filewrite ($file,"text/data")

FileClose($file)

Link to comment
Share on other sites

do you mean, i should change with my url on the IP address you mentioned?

10 hours ago, AfrozAhmed said:

Hi,

I wanted to know how to extract the data from the output page which gets a different URL after submitting the form in a website. below is the code that i am using, the highlighted in GREEN is the url where i submit the form by clicking load button after that the output is shown in different url highlighted in RED, i dont know how to retain the control to that output page and save the data in text file. Any help highly appreciated.

 

#include <IE.au3>
#include <Date.au3>
#include <INet.au3>


$oIE = _IEAttach("Welcome", "Title")    
If @error == 7 Then ;If no window is found...

    $oIE = _IECreate("http://www.hajcommittee.in/") 
EndIf

_IELoadWait($oIE, 500)  ;Wait for the page to finish loading.

$oForm = _IEGetObjById($oIE, "form1")  
$oLogin = _IEFormElementGetObjByName($oForm, "ctl00$ContentPlaceHolder1$txtCoverNo") 
_IEFormElementSetValue($oLogin, "TNF-753-4-0")
$oButton=_IEGetObjById($oIE,"ContentPlaceHolder1_btnCoverInquiry")
_IEAction ($oButton, "click")


$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, _INetGetSource("http://www.hajcommittee.in/cover_inquiry.aspx"))
;filewrite ($file,"text/data")

FileClose($file)

 

Link to comment
Share on other sites

If the link with the IP works for you and provide the expected data, then get away from IE and just use this 3 lines of code because it's a much more simple/fast/clean way  :)

Else if you want to use IE, it's the same approach. The results after entering the ID display in a iframe whose link appears in the source code of the page, and it's this link which is mentioned in my script

BTW the link in your code didn't work for me, but this one did : http://www.hajcommittee.gov.in/

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...