Jump to content
Sign in to follow this  
gcue

parsing information from html source

Recommended Posts

gcue

from several lines of html code, i am trying to get a link (ipp://PRINTERS/ipp/S-IV1-HP4350PS) based on a print queue name (S-IV1-HP4350PS)

</TR><TR><TD width='40%'><A href="isinstf.htm?ippPrinterURL=ipp://PRINTERS/ipp/S-IV1-HP4350PS&onInstalled=alert&onNotInstalled=install"><IMG SRC='/ippdocs/images/iprint.gif' BORDER=0>S-IV1-HP4350PS</A></TD>

i have a tried a few things to no avail

$uri = StringRegExp($aTableData[0][$x], "(?<=PrinterURL" & $printer_queue_name & " )[^\v]+", 1)

thanks in advance

Share this post


Link to post
Share on other sites
PowerCat

Dirty, but it works!

$str='</TR><TR><TD width=40%><A href="isinstf.htm?ippPrinterURL=ipp://PRINTERS/ipp/S-IV1-HP4350PS&onInstalled=alert&onNotInstalled=install"><IMG SRC=/ippdocs/images/iprint.gif BORDER=0>S-IV1-HP4350PS</A></TD>'

$pos1 = StringInStr($str, "ipp:", 0, 1)
$pos2 = StringInStr($str, "&on", 0, 1, $pos1)

$str1 = StringMid($str, $pos1, $pos2 - $pos1)

ConsoleWrite($str1 & @CRLF)

Share this post


Link to post
Share on other sites
gcue

thanks powercat but it doesnt work.. maybe because the string is 781 lines =) and theres other instances ipp: and &on but for different printers

Edited by gcue

Share this post


Link to post
Share on other sites
GEOSoft

What does $aTableData[0][$x] look like?

If it's the (sloppy html) code you posted above then try

$s_String = "</TR><TR><TD width='40%'><A href="isinstf.htm?ippPrinterURL=ipp://PRINTERS/ipp/S-IV1-HP4350PS&onInstalled=alert&onNotInstalled=install"><IMG SRC='/ippdocs/images/iprint.gif' BORDER=0>S-IV1-HP4350PS</A></TD>
$s_Printer = "S-IV1-HP4350PS"
$uri = StringRegExpReplace($s_String, "(?i).+?<a href=.+?url=(.+?/" & $s_Printer & ").*", "$1")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
gcue

in this case $aTableData[0][$x] = S-IV1-HP4350PS

i ran what you gave me and it captures S-IV1-HP4350PS

i am trying to get ipp://PRINTERS/ipp/S-IV1-HP4350PS

getting close!!

thanks GEO for your help

Edited by gcue

Share this post


Link to post
Share on other sites
GEOSoft

I had the input string messed up but the expression should be correct. Run this code as is and see what you get.

$s_String = "</TR><TR><TD width='40%'>" & '<A href="' & 'isinstf.htm?ippPrinterURL=ipp://PRINTERS/ipp/S-IV1-HP4350PS&onInstalled=alert&onNotInstalled=install">' & "<IMG SRC='/ippdocs/images/iprint.gif' BORDER=0>S-IV1-HP4350PS</A></TD>"
$s_Printer = "S-IV1-HP4350PS" ;; Change this to $aTableData[0][$x] in a loop
$uri = StringRegExpReplace($s_String, "(?i).+?<a href=.+?url=(.+?/" & $s_Printer & ").*", "$1")
MsgBox(0, "Result", $uri)
;ClipPut($uri)

I get "ipp://PRINTERS/ipp/S-IV1-HP4350PS"

If that's not giving you the correct result then I suspect something else in the html is causing it. A line break perhaps?

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
GEOSoft

No problem. Glad it worked out


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.