Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please Help, Excel extraction and paste to Website - Loop
#4
I started working on this but had quit. In the meantime Gint gave an example that works.

My first thoughts on this was to not open up the browser and use a string format to send a url request directly to the anywho PHP server side program and then parsing out the html returned all with QM.

Here's what I got:
It crashes under certain instances...like mispellings and things. I'm sure Gint could whip up a better way of extracting information from the anywho html results. Works pretty good otherwise Smile
Function AnyWho_Lookup
Code:
Copy      Help
function ARRAY(str)&ReturnInformation [str'First] [str'Last] [str'State] [str'City] [str'Zip]

str AnyWhoURL.format("http://whitepages.anywho.com/results.php?&qc=%s&qf=%s&qn=%s&qs=%s&qz=%s" City First Last State Zip)

HtmlDoc d.InitFromWeb(AnyWhoURL)
str AnyWhoHTML=d.GetHtml
err
,str& Entry=ReturnInformation[];Entry.from("No Matches")
,ret

ARRAY(str) a ExactMatch Information
d.GetTable(12 a)
str Match=a
ARRAY(str) NumberOfResults

findrx(Match "Found (\d+)" 0 0 NumberOfResults)
int NumberMatch=val(NumberOfResults[1])
err
,d.GetTable(13 ExactMatch)
,tok(ExactMatch[0] Information -1 "[]" 16)
,;out Information[0]
,err
,,&Entry=ReturnInformation[];Entry.from("No Matches")
,,ret
,&Entry=ReturnInformation[];Entry.from(Information[0])
,&Entry=ReturnInformation[];Entry.from(Information[1])
,&Entry=ReturnInformation[];Entry.from(Information[2])
,&Entry=ReturnInformation[];Entry.from(Information[3])
,ret

tok(Match Information -1 "[]" 16)
int i=3
if NumberMatch<10
,int RepNumber=NumberMatch
else
,RepNumber=10
rep RepNumber
,&Entry=ReturnInformation[];Entry.from(Information[i])
,&Entry=ReturnInformation[];Entry.from(Information[i+1])
,&Entry=ReturnInformation[];Entry.from(Information[i+2])
,&Entry=ReturnInformation[];Entry.from(Information[i+3])
,&Entry=ReturnInformation[];Entry.from("-------")
,i+10

Function QM_411
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 179 317 "QM 4-1-1"
;3 Edit 0x54030080 0x200 9 9 96 14 ""
;4 Edit 0x54030080 0x200 9 27 96 14 ""
;5 Edit 0x54030080 0x200 9 45 96 14 ""
;6 Edit 0x54030080 0x200 9 63 96 14 ""
;7 Edit 0x54030080 0x200 9 81 96 14 ""
;8 Static 0x54000000 0x0 108 12 48 13 "First"
;9 Static 0x54000000 0x0 108 30 48 12 "Last"
;10 Static 0x54000000 0x0 108 48 48 12 "City"
;11 Static 0x54000000 0x0 108 66 48 12 "State"
;12 Static 0x54000000 0x0 108 84 48 13 "Zip"
;17 Button 0x54032000 0x0 9 99 72 21 "Get Information"
;13 Edit 0x54231044 0x200 9 123 148 183 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030105 "" "" ""
str controls = "3 4 5 6 7"
str e3 e4 e5 e6 e7
if(!ShowDialog("QM_411" &QM_411 &controls)) ret

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 17
,str First.getwintext(id(3 win("QM 4-1-1" "#32770")))
,str Last.getwintext(id(4 win("QM 4-1-1" "#32770")))
,str State.getwintext(id(6 win("QM 4-1-1" "#32770")))
,str City.getwintext(id(5 win("QM 4-1-1" "#32770")))
,str Zip.getwintext(id(7 win("QM 4-1-1" "#32770")))
,ARRAY(str) Information
,AnyWho_Lookup Information First Last State City Zip

,str sInformation=Information
,sInformation.setwintext(id(13 win("QM 4-1-1" "#32770")))
,
,case IDOK
,case IDCANCEL
ret 1

Some work would still be needed to write to excel file.

Jimmy Vig


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)