anyday Posted April 27, 2006 Share Posted April 27, 2006 (edited) im needing some advice on help with stringsim trying to pull some information out of a web page source here is part of the source im looking atLets say my gui someone puts in the address off 6387 Tulane to search. well im trying to figure out the best way to grab the url associated with that address which in the source below would be <a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073300&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">and store that url in a var<TABLE BORDER=0><tr bgcolor='#ccccff'><td></td><th width="300">OWNER NAME</th><th width="300">ADDRESS</th></tr><TR bgcolor=F0F0FF><td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073300&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">Display</a></td><TD>ZOCCOLA WANDA L (LE)</td><TD> 6387 TULANE, HORN LAKE</td></TR><TR bgcolor=FFFFFF><td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073400&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">Display</a></td><TD>JONES JAMES A ETUX</td><TD> 6405 TULANE, HORN LAKE</td></TR><TR bgcolor=F0F0FF><td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073500&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">Display</a></td><TD>LEIGH ROBERT E III PROP LP</td><TD> 6411 TULANE, HORN LAKE0</td> Edited April 27, 2006 by anyday Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 27, 2006 Share Posted April 27, 2006 HI, and what is the question? So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
seandisanti Posted April 27, 2006 Share Posted April 27, 2006 im needing some advice on help with stringsim trying to pull some information out of a web page source here is part of the source im looking atdoes it matter what info is pulled? sorry, just kind of vague. check out the string functions in the helpfile, or the stringregexp() tutorial, or if you can give more details someone may be able to help you more directly Link to comment Share on other sites More sharing options...
anyday Posted April 27, 2006 Author Share Posted April 27, 2006 sorry hit submit post instead of preview it should all be there now Link to comment Share on other sites More sharing options...
seandisanti Posted April 27, 2006 Share Posted April 27, 2006 im needing some advice on help with stringsim trying to pull some information out of a web page source here is part of the source im looking atLets say my gui someone puts in the address off 6387 Tulane to search. well im trying to figure out the best way to grab the url associated with that address which in the source below would be <a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073300&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">and store that url in a varcheck out StringRegExp() there is a good tutorial in the tutorials section of the beta helpfile. you can make a pattern that finds the address, then ignores the tags, then grabs the next section, and have the whole thing done in one line. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 27, 2006 Moderators Share Posted April 27, 2006 So if this address is found, what is the exact information you want to pull, and what is the desired output? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
anyday Posted April 27, 2006 Author Share Posted April 27, 2006 if the address is found i want it just to pull the url that corresponds to that address out into a $var so that i can browse to that url ive coded everything but the getting the url out of the body of the html Link to comment Share on other sites More sharing options...
seandisanti Posted April 27, 2006 Share Posted April 27, 2006 (edited) So if this address is found, what is the exact information you want to pull, and what is the desired output?pay attention, smoke. he wants the link.***edit***i've got ten minutes before lunch and should probably practice my regexp anyway. i'll see if i can't whip that up real quick Edited April 27, 2006 by cameronsdad Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 27, 2006 Moderators Share Posted April 27, 2006 pay attention, smoke. he wants the link.***edit***i've got ten minutes before lunch and should probably practice my regexp anyway. i'll see if i can't whip that up real quickI was paying attention, I asked for what the "exact" output would look like. I already wrote a function to do this is why. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 27, 2006 Share Posted April 27, 2006 (edited) Hi, maybe #include <file.au3> $search = '6387 Tulane' Dim $aRecords If Not _FileReadToArray("i.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] ;Msgbox(0,'Record:' & $x, $aRecords[$x]) If StringInStr($aRecords[$x], $search) <> 0 Then MsgBox(0,"",_StringBetween1($aRecords[$x-2], '<td><a href="', '>Display</a></td>')) EndIf Next Func _StringBetween1($s_String, $s_Start = 0, $s_End = 0) $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start) Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start) EndFunc ;==>_StringBetween1 i.txt <TABLE BORDER=0> <tr bgcolor='#ccccff'> <td></td> <th width="300">OWNER NAME</th> <th width="300">ADDRESS</th> </tr> <TR bgcolor=F0F0FF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073300&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">Display</a></td> <TD>ZOCCOLA WANDA L (LE)</td> <TD> 6387 TULANE, HORN LAKE</td> </TR><TR bgcolor=FFFFFF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073400&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">Display</a></td> <TD>JONES JAMES A ETUX</td> <TD> 6405 TULANE, HORN LAKE</td> </TR><TR bgcolor=F0F0FF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073500&smurfid=0020f0f4f9f0f5f8f1f3f3f0f3f0f2f0f0f6f0f4f2f7f0f3f2f8f1f3f7f4f0f7">Display</a></td> <TD>LEIGH ROBERT E III PROP LP</td> <TD> 6411 TULANE, HORN LAKE0</td> So long, Mega Edited April 27, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
anyday Posted April 27, 2006 Author Share Posted April 27, 2006 (edited) dont know if this matters but in IE the source displays's this way The previous source was in firefox which did not include the   Smoke if your asking what the url points to its just data on house's tax assessor data that i will sooner or later have displayed in the gui of my script but at this point i just need to get the url and navigate to it <TABLE BORDER=0> <tr bgcolor='#ccccff'> <td></td> <th width="300">OWNER NAME</th> <th width="300">ADDRESS</th> </tr> <TR bgcolor=F0F0FF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073300&smurfid=0020f0f4f9f0f5f5f1f3f4f9f1f9f2f0f0f6f0f4f2f7f2f6f6f1f0f2f1f3f7f9">Display</a></td> <TD>ZOCCOLA WANDA L (LE)</td> <TD> 6387 TULANE, HORN LAKE</td> </TR><TR bgcolor=FFFFFF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073400&smurfid=0020f0f4f9f0f5f5f1f3f4f9f1f9f2f0f0f6f0f4f2f7f2f6f6f1f0f2f1f3f7f9">Display</a></td> <TD>JONES JAMES A ETUX</td> <TD> 6405 TULANE, HORN LAKE</td> </TR><TR bgcolor=F0F0FF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073500&smurfid=0020f0f4f9f0f5f5f1f3f4f9f1f9f2f0f0f6f0f4f2f7f2f6f6f1f0f2f1f3f7f9">Display</a></td> <TD>LEIGH ROBERT E III PROP LP</td> <TD> 6411 TULANE, HORN LAKE0</td> </TR><TR bgcolor=FFFFFF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073600&smurfid=0020f0f4f9f0f5f5f1f3f4f9f1f9f2f0f0f6f0f4f2f7f2f6f6f1f0f2f1f3f7f9">Display</a></td> <TD>FRANKLIN ELVIRA L</td> <TD> 6433 TULANE, HORN LAKE0</td> </TR><TR bgcolor=F0F0FF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200073700&smurfid=0020f0f4f9f0f5f5f1f3f4f9f1f9f2f0f0f6f0f4f2f7f2f6f6f1f0f2f1f3f7f9">Display</a></td> <TD>JACKSON-COLEMAN IRREVOCABLE</td> <TD> 6445 TULANE, HORN LAKE</td> </TR><TR bgcolor=FFFFFF> <td><a href="APDSPREC.pgm?TASK=disp&Getparcel=108833010%20%20%20%20%20%200072400&smurfid=0020f0f4f9f0f5f5f1f3f4f9f1f9f2f0f0f6f0f4f2f7f2f6f6f1f0f2f1f3f7f9">Display</a></td> <TD>PRUITT MARILYN ETVIR</td> <TD> 6446 TULANE, HORN LAKE0</td> </TR><TR bgcolor=F0F0FF> Edited April 27, 2006 by anyday Link to comment Share on other sites More sharing options...
seandisanti Posted April 27, 2006 Share Posted April 27, 2006 I was paying attention, I asked for what the "exact" output would look like. I already wrote a function to do this is why.fine then. no output, just stored url to variable. oh yeah, i won a few sit and go's last night. good stuff. gonna play live tourney tonight. off to lunch now... Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 27, 2006 Share Posted April 27, 2006 HI, okay then you have to change the searchstring to $search = '6387 TULANE' Hope that helps. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
anyday Posted April 27, 2006 Author Share Posted April 27, 2006 (edited) Mega: i tried your code out , seems to work i got a message box that pops up 5 times with url's only thing is should just be 1 url for the match to address and store it in a var. but thanks alot you gave me something to go off of Edited April 27, 2006 by anyday Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 27, 2006 Moderators Share Posted April 27, 2006 Here's a stab at it:$FileLocation = @DesktopDir & '\SomeFileName.txt' $Address = "6387 TULANE" $HrefArray = _StringRE_Between($FileLocation, '<a href="', '">Display') $NameAddyArray = _StringRE_Between($FileLocation, '<TD>', '</td>') For $x = 0 To UBound($NameAddyArray) - 1 If StringInStr($NameAddyArray[$x], $Address) Then MsgBox(0, 'Test', 'Url = ' & $HrefArray[$x - 1] & @CR & _ 'Name = ' & $NameAddyArray[$x - 1] & @CR & _ 'Address = ' & $NameAddyArray[$x]) ExitLoop EndIf Next Func _StringRE_Between($s_FilePath, $s_Start, $s_End) $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $a_Array = StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error Then Return $a_Array EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
anyday Posted April 27, 2006 Author Share Posted April 27, 2006 (edited) smoke, is there a var in there someone with the url as output? i ran your code but didnt do anything visually. cant make out if there is a var that is the url i see there is a msgbox command in there but i never get a msgbox Edited April 27, 2006 by anyday Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 27, 2006 Moderators Share Posted April 27, 2006 (edited) smoke,is there a var in there someone with the url as output?i ran your code but didnt do anything visually. cant make out if there is a var that is the url i see there is a msgbox command in there but i never get a msgboxAll of the links are returned in a seperate array. $HrefArray... , because you have to find the address first, and the address is in another array, and it looked like it was always the 2nd option under name.All I did was copy your example with name and address, and save that to a text file. And parse from there.Edit:And once the address is found, the Url is - 1 from the point that the address was found. If you did name, it would be the same value as $x.Edit2:Now that I think about that, my logic is flawed . Edited April 27, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
anyday Posted April 27, 2006 Author Share Posted April 27, 2006 i tried msgbox(0, "", $HrefArray[1]) no result. an the link comes first then the name then the address Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 27, 2006 Moderators Share Posted April 27, 2006 (edited) i tried msgbox(0, "", $HrefArray[1]) no result.an the link comes first then the name then the addressHere, if URL for the Address is all you want:$FileLocation = @DesktopDir & '\SomeFileName.txt' $Address = "6405 TULANE" $URL = _GetURL($FileLocation, $Address) MsgBox(64, 'URL', $URL) Func _GetURL($h_FileName, $s_Address) Local $aArray = _StringRE_Between($FileLocation, '<td>', '</td>') If IsArray($aArray) Then For $xCount = 0 To UBound($aArray) - 1 If StringInStr($aArray[$xCount], $s_Address) Then $ReturnURL = StringRegExp($aArray[$xCount - 2], '(?i:<a href=")(.*?)(?i:</a>)', 3) If IsArray($ReturnURL) Then Return $ReturnURL[0] Return 0 EndIf Next Else Return 0 EndIf Return 0 EndFunc Func _StringRE_Between($s_FilePath, $s_Start, $s_End) $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $a_Array = StringRegExp($h_FRead, '(?i:' & $s_Start & ')(.*?)(?i:' & $s_End & ')', 3) If Not @error Then Return $a_Array EndFuncThat worked for me with what you provided.Edit:And if you want to ever use the name, you can use 1 as the last parameterexpandcollapse popup$FileLocation = @DesktopDir & '\SomeFileName.txt' $Address = "6405 TULANE" $URL = _GetURL($FileLocation, $Address) MsgBox(64, 'URL From Address', $URL) $Name = "JONES JAMES A ETUX" $URL = _GetURL($FileLocation, $Name, 1) MsgBox(64, 'URL From Name', $URL) Func _GetURL($h_FileName, $s_Address_Name, $i_Address_Name = 0) Local $aArray = _StringRE_Between($FileLocation, '<td>', '</td>') If IsArray($aArray) Then If $i_Address_Name = 0 Then For $xCount = 0 To UBound($aArray) - 1 If StringInStr($aArray[$xCount], $s_Address_Name) Then $ReturnURL = StringRegExp($aArray[$xCount - 2], '(?i:<a href=")(.*?)(?i:</a>)', 3) If IsArray($ReturnURL) Then Return $ReturnURL[0] SetError(1) Return 0 EndIf Next ElseIf $i_Address_Name = 1 Then For $xCount = 0 To UBound($aArray) - 1 If StringInStr($aArray[$xCount], $s_Address_Name) Then $ReturnURL = StringRegExp($aArray[$xCount - 1], '(?i:<a href=")(.*?)(?i:</a>)', 3) If IsArray($ReturnURL) Then Return $ReturnURL[0] SetError(1) Return 0 EndIf Next Else SetError(3) Return 0 EndIf Else SetError(2) Return 0 EndIf SetError(1) Return 0 EndFunc Func _StringRE_Between($s_FilePath, $s_Start, $s_End) $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $a_Array = StringRegExp($h_FRead, '(?i:' & $s_Start & ')(.*?)(?i:' & $s_End & ')', 3) If Not @error Then Return $a_Array EndFunc Edited April 27, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
anyday Posted April 27, 2006 Author Share Posted April 27, 2006 (edited) thanks smoke, i will tryalso thanks mega, i tried your's and seems to be workinganother ques:lets say the url it comes up with ishttp://www.desotoms.info/Webpgms/APDSPREC....7f2f2f5f4f8f2f4is there an easy way to get some general info from that page like Landowner name: and such?found one way using the _StringBetween1 from mega. thanks again.in theat stringbetween1 function, is there a way to do _StringBetween1($text, 'Landowner Name:', @CR)or whatever it is for the next line Edited April 27, 2006 by anyday Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now