Jump to content

Click IE links for Pop Up window and get data from it


Recommended Posts

Hi Team,

Please help me to solve this problem. I have to retrieve information from pop up windows (eg: http://www.entheosweb.com/website_templates/business1/preview.htm) opened by clicking links (eg: click me) of home IE, http://www.entheosweb.com/website_design/pop_up_windows.asp. The pop windows has to be closed once information is retrieved and go to the next link of home IE.

The constrain here is, I cannot match link (“click me”) but the text before it (“allows you to open a browser window in any size you specify”) to select the link from the set of links.

Thanks,

Thomas

Note : attached source code and expected output file for your reference

source code :

output.txtsource_code.au3

#include <IE.au3>

$oIE = _IECreate ("http://www.entheosweb.com/website_design/pop_up_windows.asp",0, 0) ;;open in invisible mode

$sText = _IEBodyReadHTML($oIE) ;;

#ConsoleWrite($sText)

Sleep(500)

If $sText Then

$subString = StringRegExp($sText, "(?i)(?s)allows you to open a browser window in any size you specify.(.+?)\s*Click here", 1)

If NOT @Error Then

ConsoleWrite($subString[0])

$fileWrite = FileOpen("Output.txt", 1)

; Check if file opened for reading OK

If $fileWrite = -1 Then

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

Exit

EndIf

FileWrite($fileWrite,$subString[0])

FileWrite($fileWrite,"******")

$oLinks = _IELinkGetCollection($sText)

For $oLink in $oLinks

$sLinkText = _IEPropertyGet($oLink, "innerText")

;ConsoleWrite($sLinkText)

;;click on the the link in the same line of "allows you to open a browser window in any size you specify"

_IEAction($oLink, "click") ;;here the link text may not be always "Click me"

$sTextPopUpIE = _IEBodyReadText($oIE)

FileWrite($fileWrite,$sTextPopUpIE)

;ExitLoop

_IEQuit ($oLink) ;;close the pop up IE window

Next

FileClose($fileWrite)

EndIf

If @Error Then

ConsoleWrite("Message:Cannot find Pattern")

EndIf

EndIf

Link to comment
Share on other sites

What does the DOM path look like? That kind of thing is often organized by a table, with text and links on a line sharing the same row (inside TR tags), and each element in it's own data cell (TD tags). In that case you identify the particular TD element with the text, and get $oTD.nextSibling, or get all links within the same TR or TD element, etc. Depends on the page layout and exactly what the relationship is between the text and the link.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...