[plt-scheme] Problem fetching a URL
At Wed, 11 Oct 2006 14:08:11 +0000, "Ian Oversby" wrote:
> >>(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.
I don't think this is incorrect behavior. The above seems to be a
rfc-compliant url. It is using semi colons as separators.
If you want the bits at the end to use & instead of ; there you'll want
to do this:
(require (lib "url.ss" "net")
(lib "uri-codec.ss" "net"))
(current-alist-separator-mode 'amp)
(url->string
(string->url
"http://uk.old.finance.yahoo.com/d/quotes.csv?s=@%5EFTMC&f=sl1d1t1c1ohgv&e=.csv"))
Robby