ConsultingJoe Posted March 14, 2006 Share Posted March 14, 2006 Hey guys, I want to make a udf fro this site:http://www.city-data.com/zips/60544.htmlinstead of 60544 you could enter your zipI was just woundering if there is and easy way to grab for example: 44,284 from the population after I grab the source.does anyone know off the top of your head how to do it.right before the number is the text:Population (2000): and after is a break:<br>so I need to grab the text after "Population (2000): " and before the very next "<br>"I tried Stringinstr then StringRight. . . it just didn't work right.Could their be a UDF for the string grab, maybe something like: StringGrab($string, $beforeStr, $afterStr)Thank you [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 14, 2006 Moderators Share Posted March 14, 2006 Try this: ;This is straight from the source $string = "Population (2000): 44,284<br>" ;The first number will always be 20 characters from the start. ;With out the population number the whole string would be 23 characters long. ;So we subtract 23 from the total length to find out how many characters to capture. $pop = StringMid($string, 20, StringLen($string)-23) MsgBox(0, "", $pop) Link to comment Share on other sites More sharing options...
ConsultingJoe Posted March 14, 2006 Author Share Posted March 14, 2006 Try this: ;This is straight from the source $string = "Population (2000): 44,284<br>" ;The first number will always be 20 characters from the start. ;With out the population number the whole string would be 23 characters long. ;So we subtract 23 from the total length to find out how many characters to capture. $pop = StringMid($string, 20, StringLen($string)-23) MsgBox(0, "", $pop)Wow, thanks that was very helpful but is there a way to search the entire source for a string in a table for example the third row<tr>, second column<td> and return that string. actually the internet explorer UDF may have something like that, I will check that. thanks again [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 14, 2006 Moderators Share Posted March 14, 2006 Maybe something like this will get you started: #include <IE.au3> ; Create an IE Browser $oIE = _IECreate() ; Navigate to your URL _IENavigate($oIE, "http://www.city-data.com/zips/60544.html") ; Get a reference to the First table on the webpage (where the data is stored) ; note that object indexes are 0-based, so the first table is index 0 $oTable1 = _IETableGetObjByIndex($oIE, 0) ; Read the table cells into a 2-D array $aDetails = _IETableWriteToArray($oTable1) ; Write the array contents out to the console For $i = 0 to Ubound($aDetails, 2) - 1 ConsoleWrite($aDetails[0][$i]) Next Exit Link to comment Share on other sites More sharing options...
w0uter Posted March 14, 2006 Share Posted March 14, 2006 why not just _InetGetSource and a bit of StringRegExp ? My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
ConsultingJoe Posted March 15, 2006 Author Share Posted March 15, 2006 WOW check this out I want to add more and even have it download the satilite view Possible UDF??? CODE$zip = InputBox("", "Enter 5 digit zip code", 90210) if StringIsDigit ( $zip ) Then if StringLen ( $zip ) = 5 Then InetGet( "http://www.city-data.com/zips/" & $zip & ".html", @ScriptDir & "\zip.html", 1 ) if FileReadline( @ScriptDir & "\zip.html" ) <> "" Then $citystate = FileReadLine ( @ScriptDir & "\zip.html" , 120 ) $pop = FileReadLine ( @ScriptDir & "\zip.html" , 121 ) $homes = FileReadLine ( @ScriptDir & "\zip.html" , 124 ) $homes = StringMid( $homes, 16 ) $homes = StringtrimRight( $homes, 4) $homes = StringReplace( $homes, ",", "") $citystate = StringMid($citystate, StringInStr ( $citystate, ".html" ) + 7 ) $citystate = StringTrimRight ( $citystate, 8 ) $citystate = StringSplit( $citystate, "," ) $city = $citystate[1] $state = $citystate[2] $state = StringMid($citystate[2], 2 ) $pop = StringMid($pop, 20, StringLen($pop)-23) $pop = StringReplace( $pop, ",", "" ) MsgBox(0, "", "City Name: " & $city & @CRLF & "State Name: " & $state & @CRLF & "Population: " & $pop & @CRLF & "Homes: " & $homes) EndIf EndIf EndIf func onautoitexit() FileDelete( @ScriptDir & "\zip.html" ) EndFunc [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] 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