<HTML><BODY>I'm making fully RFC6265 compliant cookie support for net/url and http.<br>https://github.com/Kalimehtar/client-cookies<br><br>It is still pre-alpha, but, I hope, will be ready in 2-3 weeks.<br><br><br>Среда,  8 января 2014, 10:33 -07:00 от Matthew Flatt <mflatt@cs.utah.edu>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
        <div id="">
        



    






        

        
        
        
        
        

        

        
        



<div class="js-helper js-readmsg-msg">
        <style type="text/css"></style>
         
        <div id="style_13892027230000000057" class="mr_read__body">
                <base target="_self" href="https://e.mail.ru/">
                
                        <div id="style_13892027230000000057_BODY">In case no one offers a better library, enclosed is a small one that I<br>
recently created for a web-scraping task.<br>
<br>
Start a simulation of a browser with `make-connection`, use `goto!` to<br>
follow a link to a relative URL (following redirects), and use `back!`<br>
to go back. The `goto!` function returns two values: the headers as a<br>
string and the page content as bytes.<br>
<br>
Beware: My application accessed a single site, so this library doesn't<br>
attempt to do the right thing with cookies across sites.<br>
<br>
At Wed, 08 Jan 2014 03:48:44 -0800, Duncan Bayne wrote:<br>
> Hi All,<br>
> <br>
> I'm trying to re-write some Common Lisp web-scraping code in Racket.<br>
> <br>
> In Common Lisp, I'm POSTing a login request, and storing the cookie-jar<br>
> for subsequent GETs:<br>
> <br>
> (defun login (username password)<br>
>   "Logs in to <a href="http://www.example.com" target="_blank">www.example.com</a>.  Returns a cookie-jar containing<br>
>   authentication details."<br>
>   (let ((cookie-jar (make-instance 'drakma:cookie-jar)))<br>
>     (drakma:http-request "<a href="http://www.example.com/login" "="" target="_blank">http://www.example.com/login"</a><br>
>              :method :post<br>
>              :parameters `(("username" . ,username) ("password" .<br>
>              ,password))<br>
>              :cookie-jar cookie-jar)<br>
>     cookie-jar))<br>
> <br>
> ; snip<br>
> <br>
> (defun get-page (page-num cookie-jar)<br>
>   "Downloads a potentially invalid HTML page containing data to scrape. <br>
>   Returns a string containing the HTML."<br>
>   (let ((url (concatenate 'string "<a href="http://www.example.com/data/" "="" target="_blank">http://www.example.com/data/"</a><br>
>   (write-to-string page-num))))<br>
>     (let ((body (drakma:http-request url :cookie-jar cookie-jar)))<br>
>       (if (search "No data found." body)<br>
>     nil<br>
>   body))))<br>
> <br>
> However, I can't find an equivalent in Racket. The latest HTTP<br>
> library[1] makes no mention of cookies at all, and AFAICT the cookie<br>
> library[2] seems more about correctly serializing and deserializing<br>
> them.<br>
> <br>
> Can anyone suggest a way of re-writing the above CL in Racket without<br>
> having to implement a bunch of header-parsing stuff?<br>
> <br>
> TIA for any help ...<br>
> <br>
> [1]<br>
> <a href="https://github.com/plt/racket/blob/master/racket/collects/net/http-client.rkt" target="_blank">https://github.com/plt/racket/blob/master/racket/collects/net/http-client.rkt</a><br>
> [2] <a href="http://docs.racket-lang.org/net/cookie.html" target="_blank">http://docs.racket-lang.org/net/cookie.html</a><br>
> <br>
> -- <br>
> Duncan Bayne<br>
> ph: +61 420817082 | web: <a href="http://duncan-bayne.github.com/" target="_blank">http://duncan-bayne.github.com/</a> | skype:<br>
> duncan_bayne<br>
> <br>
> I usually check my mail every 24 - 48 hours.  If there's something<br>
> urgent going on, please send me an SMS or call me.<br>
> ____________________<br>
>   Racket Users list:<br>
>   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div>
                        <div>____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</div>
                
                <base target="_self" href="https://e.mail.ru/">
        </div>

        
</div>


</div>
</blockquote>
<br>
<br>-- 
<br>Roman Klochkov<br></BODY></HTML>