I’m working on a script to parse a page source and create iCal events based on a schedule. I’m having a little issue though with getting the source set though. Here is my bit of trouble code:
tell application "Google Chrome"
activate
set theurl to URL of active tab of window 1 as text -- Obtain URL string
set curlCmd to "curl" & " " & quoted form of theurl -- Prepare for script with quoted URL to account for request notation
set thesource to do shell script curlCmd -- Set outputted source for parsing
end tell
After running here is the output:
I’ve obscured the URL’s for my companies privacy, but the URL’s contain special characters and have no spaces but are rather long. I’ve tested this same code on various sites (including this one) and it works fine, is there some other modifier outside of ‘quoted form of’ I should be using to read the URL correctly?
Thank you for any and all help
Model: Macbook Pro 15" i7
AppleScript: 2.4.1
Browser: Chrome 15.0.874.121
Operating System: Mac OS X (10.7)
Please no bumps, I think if no one knows, no one knows.
Here’s my thought - how are you CURLing? Because I’ve used that and you need a file, and a destination, optionally it’ll take user/pass and a few other options. Do you have a destination? Just looking at your code it appears you get a page, but have nothing else.
Here’s an example of what I use:
set theCURLCommand to (“curl -u UserName:PassWord ftp://our.serverName.com/folder/” & " -T " & (quoted form of POSIX path of theFilePath))
So, does your URL have embedded in it the location or options? If so, then you might have to do something to break it up. Quoted form of theURL wouldn’t work since it would quote the whole thing, but say you’d need to break theURL into source parts and destination parts with separate quoting.
Also, my listing of error says -10004: A privilege violation occurred. Maybe you need to add user/pass to your CURL.
I was using curl to grab the source of the page but I went about it another, workaround way:
Pulling source from webpage
tell application "Google Chrome"
activate
view source of active tab of window 1
delay 3
repeat while loading of active tab of window 1
delay 3
end repeat
select all of active tab of window 1
copy selection of active tab of window 1
end tell
delay 1
set thesource to the clipboard
Then using offsets and delimiters to extract dates and times for a schedule. Then adding them to iCal:
tell application "iCal"
tell calendar "Home"
set startdate to date "Friday, December 2, 2011 2:00:00 AM"
set enddate to date "Friday, December 2, 2011 3:00:00 PM"
make new event at end with properties {summary:"Title", location:"Location", start date:startdate, end date:enddate}
end tell
end tell
But I had another question, as far as date parameters go in iCal, can I include string variables? i.e.
set month to "December"
set startdate to date "Friday, " & month & " 2, 2011 2:00:00 AM"