Extract Tag - Extracting HREF Link

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
lsingbiel
Newbie
Posts: 3
Joined: Sat Mar 22, 2008 3:27 am
Location: Los Angeles
Contact:

Extract Tag - Extracting HREF Link

Post by lsingbiel » Sat Mar 22, 2008 7:37 pm

Hello,

I'm attempting to extract a link from a page, because the link itself contains information that I need to write to a log file. I basically just need to extract the link and save it to a variable, then I can then use MIDSTR to extract the information that I need from the link, as it always appears in the exact same position in the link. In this instance, it's an arbitrary folder number that the link text itself does not list, so I can't find a way to extract it via an Extract Tag option, because it only extracts the text of the link, rather than the link itself.

One workaround that I have been using has been to do the following:

Code: Select all

Let>FolderName={"FrontSt"}
Press CTRL
Send Character/Text>f
Release CTRL
Wait>1
Send Character/Text>%FolderName%
Wait>0.2
Press TAB
Wait>0.2
Send Character/Text>%SPACE%
Wait>0.2
Press TAB
Wait>0.2
Send Character/Text>%SPACE%
Wait>0.2
Press ENTER
Wait>1.5
Press ESC
Wait>0.5
Press TAB
Wait>0.2
Press SHIFT
Press F10
Release SHIFT
Wait>0.2
Send Character/Text>t
Wait>0.7
WaitClipBoard
GetClipBoard>FullLinkHREF
MidStr>FullLinkHREF,31,6,FolderNumber
What the above script does is it brings up the Internet Explorer "Find" window, then it searches for the EXACT text of the folder name, which is "FrontSt" for the purposes of this example. It then tabs over to select "Match whole word only" and then "Match Case", then it finds it on the page. Then it presses tab once to focus on the link itself, then SHIFT-F10 simulates a Right-mouse click, then "t" copies target to clipboard, which is then saved as the variable "FullLinkHREF". The folder number that I need to capture starts at the 31st character in the link, and it's 6 characters long, so the MIDSTR captures this and saves it to the variable "FolderNumber".

The problem is that my method can be unreliable, especially when the same exact text as the "FolderName" shows up elsewhere on the page. Does anyone know of another way to grab ONLY the HREF link via an Extract Tag function? Any help would be appreciated. Thanks so much for your help!

~Len Singbiel

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Mar 22, 2008 8:26 pm

You could probably use VBScript RegEx against the source file for the web page.

Rough outline:
----------------------------------
HTTPGet > from web page to %GotPage%

VB EVAL RegEx for , in %GotPage%, result to %FullLinkHREF%

MidStr>FullLinkHREF,%Position%,%Count%,FolderNumber
----------------------------------
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts