Page 1 of 1
problem with my lisp function
Posted: Wed Dec 16, 2009 5:48 am
by djdebaviere
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)))))
Re: problem with my lisp function
Posted: Wed Dec 16, 2009 9:31 am
by nuntius
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 "
" blocks, good indentation, and preview so we don't have to specially parse

.
Re: problem with my lisp function
Posted: Wed Dec 16, 2009 10:06 am
by djdebaviere
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)))))
Re: problem with my lisp function
Posted: Wed Dec 16, 2009 10:10 am
by djdebaviere
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
Re: problem with my lisp function
Posted: Wed Dec 16, 2009 10:42 am
by nuntius
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?