 |
| Forum King |
 |
Joined: Sat Apr 19, 2008 7:16 pm Posts: 1253 Location: United States Given: 53 thanks Received: 544 thanks Known Programming Languages: AHK, C#, PHP
|
This code snippet downloads an identity from Fake Name Generator and even parses it all for you so that you can immediately use the data. It only takes a few seconds to implement and works really well. You can remove unnecessary fields if you don't want to use them. - ; Fetch the fake name generator page
- UrlDownloadToFile, http://www.fakenamegenerator.com/, fng.htm
- FileRead, fng, fng.htm
- FileDelete, fng.htm
-
- ; Parse out the vCard URL that has all the important info
- regex := "(?<=/fireform.php\?identity=).*?(?="">)"
- RegExMatch(fng, regex, info)
-
- ; Separate the data into separate strings
- StringReplace, info, info, --, /, All ; Workaround to allow AHK to use more than one character as a delimiter in a parse loop
- Loop, Parse, info, /
- {
- if A_Index = 1
- firstName = %A_LoopField%
- if A_Index = 2
- lastName = %A_LoopField%
- if A_Index = 3
- salutation = %A_LoopField%
- if A_Index = 4
- street = %A_LoopField%
- if A_Index = 5
- zipCode = %A_LoopField%
- if A_Index = 6
- state = %A_LoopField%
- if A_Index = 7
- city = %A_LoopField%
- if A_Index = 8
- phone = %A_LoopField%
- if A_Index = 9
- birthDay = %A_LoopField%
- if A_Index = 10
- birthMonth = %A_LoopField%
- if A_Index = 11
- birthYear = %A_LoopField%
- if A_Index = 12
- age = %A_LoopField%
- if A_Index = 13
- email = %A_LoopField%
- }
Here's an example of how it could be tested: - email := UrlDecode(email)
- StringReplace, city, city, +,%A_Space%, All
- StringReplace, street, street, +,%A_Space%, All
-
- MsgBox, Name: %salutation% %firstName% %lastName%`nAddress: %street%`nCity: %city%, %state% %zipCode%`nPhone: %phone%`nBirth date: %birthDay%/%birthMonth%/%birthYear%`nAge: %age%`nEmail: %email%
- return
_________________ GSN Oodles Answer Database - The original answer database, now serving over eight thousand answers. gPrize - A fast, lightweight, and customizable Oodles prize checker.
|
|