Curl within applescript returns empty result

For some time I have been using Curl commands from within an applescript to return daily or weekly share prices to filemaker pro database fields. This week the weekly script returns an empty result. It is: set incomingtext to do shell script "curl -s " & quoted form of (“http://ichart.finance.yahoo.com/table.csv?s=” & theticker & startfinishdates) where eg ticker=ebay and the startfinishdates compiled in filemaker for this week are: &b=17&a=03&c=2017&e=22&d=03&f=2017&g=d In a similar csv request from chrome header of http://ichart.finance.yahoo.com/table.csv?s=ebay&a=03&b=17&c=2017&d=03&e=21&f=2017&g=d works as a csv dowload but I can not make a Curl equivalent. I understand Curl is see url and the -s is for silent but beyond that research is difficult. I note that the characters immediately after the ticker &a or &b appear to dictate american mdy or english dmy or date formats. The daily curl command still works fine. Any help appreciated. Roger

Model: MacPro5,1
AppleScript: AppleScript 2.1.2
Browser: Version 49.0.2623.112 (64-bit)
Operating System: Mac OS X (10.6.8)

Here,

set theCmd to "https://ichart.finance.yahoo.com/table.csv?s=ebay&a=03&b=17&c=2017&d=03&e=21&f=2017&g=d"

do shell script "curl -s " & quoted form of theCmd

as well as

set theCmd to "https://ichart.finance.yahoo.com/table.csv?s=ebay&a=03&b=17&c=2017&d=03&e=21&f=2017&g=d"

do shell script "curl " & quoted form of theCmd

behaved flawlessly.

returning :
[format]“Date,Open,High,Low,Close,Volume,Adj Close
2017-04-21,32.689999,32.689999,31.940001,32.18,14319900,32.18
2017-04-20,32.860001,33.040001,32.32,32.529999,28090100,32.529999
2017-04-19,34.200001,34.34,33.779999,33.849998,13710900,33.849998
2017-04-18,34.110001,34.369999,33.810001,34.02,7485300,34.02
2017-04-17,34.349998,34.439999,34.09,34.439999,6919900,34.439999”[/format]

Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) samedi 22 avril 2017 13:08:50

Yes. It just needs the “http://” changing to “https://”.

Hey Roger,

Please for goodness sake give us a properly formatted script using the [AppleScript] button in the editor, so we don’t have to assemble a puzzle to help you.

If at all possible it should be a script that actually works as well.

An example of same:


set theticker to "ebay"
set startfinishdates to "&b=17&a=03&c=2017&e=22&d=03&f=2017&g=d"

set shCMD to "curl -Ls --user-agent 'Opera/9.70 (Linux ppc64 ; U; en) Presto/2.2.1' " & quoted form of ("http://ichart.finance.yahoo.com/table.csv?s=" & theticker & startfinishdates)
set incomingtext to do shell script shCMD

Note the “L” or “–location” switch which turns on redirects.

Note also that it’s a good idea to employ a user-agent string to prevent the target from knowing curl is the agent.

I’ve used the one in the script for years, because it’s rather old and sometimes gets servers to provide better information.

But you can find many alternatives here:

https://udger.com/resources/ua-list


Chris
··················································································
{ MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.12.4 }