[plt-scheme] Problem fetching a URL

From: Ian Oversby (oversby at hotmail.com)
Date: Wed Oct 11 10:08:11 EDT 2006

>>(require (lib "url.ss" "net"))
>>
>>(display-pure-port
>>(get-pure-port
>>  (string->url 
>>"http://uk.old.finance.yahoo.com/d/quotes.csv?s=@%5EFTMC&f=sl1d1t1c1ohgv&e=.csv")))
>>
>>
>>Pasting the URL into my browser works correctly and also simpler URLs such 
>>as http://www.google.com/ do not give the same problem.
>>
>>This is happening on version 3.52 of mzscheme running on Windows.
>
>It took me a while to realize the "Missing Format Variable" wasn't
>a Scheme error message - it is generated by the Yahoo server...

I wouldn't have suspected this - thanks for the pointer.  I had a look
at what the URL is being converted to.

http://uk.old.finance.yahoo.com/d/quotes.csv?s=%40%5EFTMC;f=sl1d1t1c1ohgv;e=.csv

i.e. it is converting ampersands to semi-colons rather than %26 which
seems like incorrect behaviour.  Is this a bug in the url library?  I'll
pre-convert the urls before passing them to string->url, cheers.

>The problem is that get-pure-port does not post the above
>information after the ? to the server. Therefore the Yahoo
>server responds with a text file containing the text
>"Missing Format Variable" (try to remove the f=s... from the
>url, then you get the same message).
>
>Anyways, use this instead:
>
>(display-pure-port
>   (post-pure-port url #"s=@%5EFTMC&f=sl1d1t1c1ohgv&e=.csv" '()))
>
>--
>Jens Axel Søgaard

Thanks for your help,

Ian




Posted on the users mailing list.