[plt-scheme] Problem fetching a URL

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Wed Oct 11 08:56:05 EDT 2006

Ian Oversby skrev:
> Hi,
> 
> I'm trying to fetch a URL using the code in the schematics cookbook but 
> it is not returning the page and is instead giving an error message: 
> "Missing Format Variable."  What am I doing wrong?
> 
> (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...

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




Posted on the users mailing list.