problem with my lisp function

Discussion of Common Lisp

problem with my lisp function

Postby djdebaviere » Wed Dec 16, 2009 5:48 am

I use this function to connect at a URL and get the html code of the page referenced by the URL. my problem is that the html code that I receive is not all of the code of the page

(defun connect-to-url (url filename)
(ext:with-http-input (stream url)

(with-open-file (stream2 filename :direction :output
:if-exists :overwrite
:if-does-not-exist :create )

(loop for line = (read-line stream nil nil)
while line
do (format stream2 line)))))
djdebaviere
 
Posts: 13
Joined: Fri Dec 04, 2009 1:30 pm

Re: problem with my lisp function

Postby nuntius » Wed Dec 16, 2009 9:31 am

Here are a couple posting suggestions; unfortunately I don't have a system handy to test your problem.

First, specify which non-core packages you are using (e.g. where ext:with-http-input comes from).

Second, use the "[code][/code]" blocks, good indentation, and preview so we don't have to specially parse :o.
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA

Re: problem with my lisp function

Postby djdebaviere » Wed Dec 16, 2009 10:06 am

Code: Select all
 
(defun connect-to-url (url filename)
    (ext:with-http-input (stream url)
   
        (with-open-file (stream2  filename :direction :output
                                 :if-exists :overwrite
                                 :if-does-not-exist :create )

           (loop for line = (read-line stream nil nil)
               while line
               do (format stream2 line)))))
djdebaviere
 
Posts: 13
Joined: Fri Dec 04, 2009 1:30 pm

Re: problem with my lisp function

Postby djdebaviere » Wed Dec 16, 2009 10:10 am

Code: Select all

(defun connect-to-url (url filename)
    (ext:with-http-input (stream url)
   
        (with-open-file (stream2  filename :direction :output
                                 :if-exists :overwrite
                                 :if-does-not-exist :create )

           (loop for line = (read-line stream nil nil)
               while line
               do (format stream2 line)))))




to run it, write (connect-to-url("URL" " path of the file")

I have run it on the Clisp and my problem is that it not return all the contain of the web page
djdebaviere
 
Posts: 13
Joined: Fri Dec 04, 2009 1:30 pm

Re: problem with my lisp function

Postby nuntius » Wed Dec 16, 2009 10:42 am

Other than stripping out line breaks, it works for me.

Your code is very similar to
http://rosettacode.org/wiki/HTTP_Request#Common_Lisp

Maybe there is a character-set issue on the page you are trying to read?
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 3 guests

cron