Re: Problem with curl
Re: Problem with curl
- Subject: Re: Problem with curl
- From: kai <email@hidden>
- Date: Sun, 13 Aug 2006 04:12:44 +0100
On 12 Aug 2006, at 10:48, Tim Mansour wrote:
I have a script I (and others) have been using for some time that
works from Address Book and looks up the Australia Post web site to
find the postcode for a contact's suburb. It's been working just
fine for some time, but now I and others are getting an error
because it's not connecting to the site (and I've double-checked
that the URL hasn't changed).
I'm wondering if a recent Security Update has made any change to
either "do shell script" or "curl" that would prevent a connection
to a web site using http, from within an AppleScript?
I just ran a successful test here (in Mac OS 10.4.6), Tim - using the
script below. You might like to try it yourself to see how it fares
on your machine. If it doesn't work for you, then that could point to
machine/system differences...
-----------
to get_list for list_type from source_text
set tid to text item delimiters
set text item delimiters to "<strong>" & list_type & ":</strong> "
set l to rest of source_text's text items
set text item delimiters to "<br />"
repeat with i in l
set i's contents to i's first text item
end repeat
set text item delimiters to tid
l
end get_list
to get_search_string for search_location
set tid to text item delimiters
set text item delimiters to "+"
set search_string to ¬
"http://www1.auspost.com.au/postcodes/index.asp?Locality=" & ¬
search_location's words & "&sub=1&State=&Postcode=&submit1=Search"
set text item delimiters to tid
quoted form of search_string
end get_search_string
to get_postcode for search_name
set search_string to get_search_string for search_name
set search_result to do shell script "curl " & search_string
set postcode_list to get_list for "POSTCODE" from search_result
set list_length to count postcode_list
if list_length is 0 then error "Could not locate a postcode for \""
& search_name & "\"."
if list_length is 1 then return postcode_list's beginning
set location_list to get_list for "LOCATION" from search_result
repeat with i from 1 to count postcode_list
tell location_list to set item i to postcode_list's item i & tab &
item i
end repeat
set chosen_location to (choose from list location_list ¬
with prompt "Please choose the correct location for " & search_name
& ":")
if chosen_location is false then error number -128
first word of chosen_location's beginning
end get_postcode
set demo_list to {"Brogo", "Mclaren Flat", "Merredin", "Paradise
Beach", ¬
"Pioneer Bay", "Cavendish", "Hillside", "Fictitious Location"}
repeat with search_name in demo_list
display alert "Get postcode for " & search_name & ¬
"?" buttons {"Cancel", "OK"} cancel button 1
try
set post_code to get_postcode for search_name
display alert "Postcode for " & search_name & ":" message ¬
post_code buttons {"Cancel", "OK"} cancel button 1
on error err_msg number err_num
if err_num is -128 then error number err_num
display alert "Postcode not found" message err_msg ¬
buttons {"Cancel", "OK"} cancel button 1 as warning
end try
end repeat
-----------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden