Sign in to follow this  
Followers 0
ConsultingJoe

Zip Code => Sensis Data

16 posts in this topic

I want to add more to this but this is just the basics. I want to make it a UDF for all.

thanks big daddy for string formating

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

please feel free to add your code and/or comments

Thanks


[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]

Share this post


Link to post
Share on other sites



I am waiting for someone to let me know what you guys think. This could be usful


[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]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Well something is wrong, this is what I got with 65536.

Also if you enter a zip code that doesn't have a page it just errors out.

Edited by big_daddy

Share this post


Link to post
Share on other sites

Well something is wrong, this is what I got with 65536.

Also if you enter a zip code that doesn't have a page it just errors out.

you're right, but most work like 90210 or 60433. there really is no fix unless i have it search for the state, city, ect because i use readline.

thanks for the input, I may work on it


[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]

Share this post


Link to post
Share on other sites

you're right, but most work like 90210 or 60433. there really is no fix unless i have it search for the state, city, ect because i use readline.

thanks for the input, I may work on it

This is a cool concept. Why don't you try to find a similar data source on the US Census Bureau site. (google it) It would also be more useful if the source page gave the Latitude and Longitude too.

Gene


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

This is a cool concept. Why don't you try to find a similar data source on the US Census Bureau site. (google it) It would also be more useful if the source page gave the Latitude and Longitude too.

Gene

yeah this is a good one but you can only use it so many times a day

http://www.zipinfo.com/search/zipcode.htm

I will work on it


[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]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Well I decided to mess around with it and came up with this:

You will need the IE.au3 UDF

#include <IE.au3>
#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <GuiStatusBar.au3>

$Form1 = GUICreate("Zip Code Fact Sheet", 620, 440, 200, 125)
$List1 = GUICtrlCreateListView("Characteristics|Numbers", 8, 50, 600, 350)
GUICtrlCreateLabel("Enter your zip code:", 16, 22, 98, 17)
$Input1 = GUICtrlCreateInput("", 120, 20, 113, 21, -1, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("GO", 240, 20, 33, 21, $BS_DEFPUSHBUTTON)
$StatusBar1 = _GuiCtrlStatusBarCreate ($Form1, 620, "", $SBT_TOOLTIPS)
_GuiCtrlStatusBarSetMinHeight ($StatusBar1, 35)
_GuiCtrlStatusBarSetText ($StatusBar1, ' Enter your zip code and click the "GO" button.')
$Progress1 = GUICtrlCreateProgress(410, 412, 200, 20)
GUICtrlSetResizing($Progress1, $GUI_DOCKSTATEBAR)
GUICtrlSetState($Progress1, $GUI_HIDE)
GUICtrlSetState ($Input1, $GUI_FOCUS)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            _GUICtrlListViewDeleteAllItems ($List1)
            _GuiCtrlStatusBarSetText ($StatusBar1, ' Looking up zip code data, Please Wait....')
            $zip = GUICtrlRead($Input1)
            If StringIsDigit($zip) And StringLen($zip) = 5 Then
                GUICtrlSetData($Progress1, 0)
                GUICtrlSetState($Progress1, $GUI_SHOW)              
                Ping("www.google.com")
                If @error Then
                    MsgBox(0, "Connection Error!", "There was a problem connecting to the internet.")
                    _GuiCtrlStatusBarSetText ($StatusBar1, ' Check you internet connection and try again.')
                    ContinueLoop
                EndIf
                $oIE = _IECreate (0)
                GUICtrlSetData($Progress1, 10)
                _IENavigate ($oIE, "http://factfinder.census.gov/servlet/SAFFFacts?_submenuId=factsheet_1&_sse=on")
                GUICtrlSetData($Progress1, 20)
                
        ; get pointers to the form and zip field
                $o_form = _IEFormGetObjByName ($oIE, "form2")
                $o_zip = _IEFormElementGetObjByName ($o_form, "_county")
                GUICtrlSetData($Progress1, 30)
                
        ; Set field values and submit the form
                _IEFormElementSetValue ($o_zip, $zip)
                _IEFormSubmit ($o_form)
                GUICtrlSetData($Progress1, 40)
                _IELoadWait ($oIE)
                GUICtrlSetData($Progress1, 60)
                
        ; Get a reference to the fourth table on the webpage (where the data is stored)
                $oTable = _IETableGetObjByIndex ($oIE, 3)
                GUICtrlSetData($Progress1, 70)
                
        ; Read the table cells into a 2-D array
                $aProfile = _IETableWriteToArray ($oTable)
                GUICtrlSetData($Progress1, 80)
                
                _IEQuit ($oIE)
                GUICtrlSetData($Progress1, 90)
                
        ; Write the array contents to the listview
                For $i = 0 To UBound($aProfile, 2) - 1
                    If $aProfile[0][$i] == 0 Then ContinueLoop
                    Local $lv_item = GUICtrlCreateListViewItem($aProfile[0][$i] & "|" & $aProfile[1][$i], $List1)
                    If $aProfile[1][$i] == "Number" Then
                        GUICtrlSetBkColor($lv_item, 0x5CACEE)
                    Else
                        If $aProfile[1][$i] <> " " Then GUICtrlSetBkColor($lv_item, 0x9FB6CD)
                    EndIf
                Next
                GUICtrlSetData($Progress1, 100)
                _GUICtrlListViewSetColumnWidth ($List1, 0, $LVSCW_AUTOSIZE)
                _GUICtrlListViewSetColumnWidth ($List1, 1, $LVSCW_AUTOSIZE_USEHEADER)
                _GuiCtrlStatusBarSetText ($StatusBar1, ' Reading zip code data complete.')
                GUICtrlSetState($Progress1, $GUI_HIDE)
            Else
                _GuiCtrlStatusBarSetText ($StatusBar1, ' Enter your zip code and click the "GO" button.')
                MsgBox(0, "Error", "You must enter a correct zip code.")
                GUICtrlSetState ($Input1, $GUI_FOCUS)
            EndIf
    EndSelect
WEnd
Exit

3/18/06:

Fixed a couple bugs

3/20/06:

Added $BS_DEFPUSHBUTTON to allow pressing enter on the input.

Added an internet connection check to keep script from just closing if no connection is present.

Edited by big_daddy

Share this post


Link to post
Share on other sites

all I have to say is WOW.

you really are BIG DADDY, lol

nice job. that is F***ING awsome


[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]

Share this post


Link to post
Share on other sites

all I have to say is WOW.

you really are BIG DADDY, lol

nice job. that is F***ING awsome

Thanks, but really it was pretty easy after I figured out how to use all the IE.au3 functions. I updated my above post with some revised code and remarks.

Share this post


Link to post
Share on other sites

Thanks, but really it was pretty easy after I figured out how to use all the IE.au3 functions.

Where do you get IE.au3 at?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Am i just being an ass and lazy for not doing search for these files? But i see no reason why the authors of these new Scripts don't give links to all the .au3 files they use. One it gives more credit to people's code they used to create there new scripts and two it makes it easier for people trying to run these new scripts?

Is this unreasonable. Or am i being unreasonable by not wanting to do search for IE.Au3?

I'm sure to you vets its like files you have had for a long time, i'm sure i used to have them as well but recently i did a reinstall and lost a lot of my autoit stuff.

Then i find i have to do searches for these Au3 files and read like sometimes 50 posts before i find the original source file. Which in my view sucks.

I think all scripts should have a comment after any .au3 file with a link to where to download said .au3 file

Of course maybe i'm just a jerk for wanting this I don't know.

Falling

Edited by Falling

Share this post


Link to post
Share on other sites

Am i just being an ass and lazy for not doing search for these files? But i see no reason why the authors of these new Scripts don't give links to all the .au3 files they use. One it gives more credit to people's code they used to create there new scripts and two it makes it easier for people trying to run these new scripts?

Is this unreasonable. Or am i being unreasonable by not wanting to do search for IE.Au3?

I'm sure to you vets its like files you have had for a long time, i'm sure i used to have them as well but recently i did a reinstall and lost a lot of my autoit stuff.

Then i find i have to do searches for these Au3 files and read like sometimes 50 posts before i find the original source file. Which in my view sucks.

I think all scripts should have a comment after any .au3 file with a link to where to download said .au3 file

Of course maybe i'm just a jerk for wanting this I don't know.

Falling

Normally the users will include all the source files needed in a zip file or state you what you need and links to them. Not everyone does that, but they soon learn to when there is enough whinning :)


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Normally the users will include all the source files needed in a zip file or state you what you need and links to them. Not everyone does that, but they soon learn to when there is enough whinning :)

Yes and my question is the whinning justified or not.

Share this post


Link to post
Share on other sites

Yes and my question is the whinning justified or not.

Depends on how you look at it. You've been a memeber since '04, and haven't actively participated much... So if you have to read 50 posts to find what it is that you 'Want' to use, maybe that's a good thing, it forces you to actively participate in AutoIt's every day activities and to know what's going on, rather than just popping in, finding what it is you want to use, and poof be gone (even though we'd rather see a contribution than a complaint :mellow: ).....

On the other hand, you'd think that, yes... most would include Non-Standard UDF's that they use in their applications that they make, some of us that even actively participate every day don't have them on hand :). So, your question remains an enigma :)


[center]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.[/center]

Share this post


Link to post
Share on other sites

Yes and my question is the whinning justified or not.

I usually do try and include links to all the non standard udf's I use in my scripts. Guess I just forgot that IE.au3 was one of those because I've had it for so long. I will update my post to include the link.

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  
Followers 0