problem with my project in common lisp

Discussion of Common Lisp

problem with my project in common lisp

Postby djdebaviere » Mon Dec 21, 2009 6:04 am

hello,
I have already posed the same problem on this forum, but I have always the same same problem in my project. My problem is the following: I must extract criticize on films in the Web site www.première.fr.
I have already a function lisp which allows to extract code HTML from the page, but my problem is qu' it is not extract well, because the code html it gives to me is incomplete. you can test and say to me how to arrange this problem.

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")

please use http://www.premiere.fr/film/Le-Dernier-Vol/(affichage)/press like URL

thanks
djdebaviere
 
Posts: 13
Joined: Fri Dec 04, 2009 1:30 pm

Re: problem with my project in common lisp

Postby Ramarren » Mon Dec 21, 2009 7:59 am

The problem is here:
Code: Select all
(format stream2 line)


You are using the line as a format control string. It fails, which you would know if you read the error message, when it encounters the tilde sign, which designates format control directives. To write a sequence to a stream use WRITE-SEQUENCE, or possibly WRITE-LINE to maintain parity with READ-LINE.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: problem with my project in common lisp

Postby djdebaviere » Mon Dec 21, 2009 10:05 am

thanks!!! it's ok now. I have use write-line and the output is good. the rest is to construct the function which return only the text of critiques. if you have an indication about a function which take a text in input and return a part of this text, help me.
djdebaviere
 
Posts: 13
Joined: Fri Dec 04, 2009 1:30 pm

Re: problem with my project in common lisp

Postby Ramarren » Mon Dec 21, 2009 11:14 am

I would use closure-html to parse the page and plexippus-xpath to extract the appropriate part.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: problem with my project in common lisp

Postby djdebaviere » Mon Dec 21, 2009 11:29 am

can you give me a small function which use closure-html and plexippus-xpath ?
djdebaviere
 
Posts: 13
Joined: Fri Dec 04, 2009 1:30 pm

Re: problem with my project in common lisp

Postby Ramarren » Mon Dec 21, 2009 11:38 am

There are examples linked from homepages of both of these libraries. Please try to make at least some effort. Also, if you do not know how HTML and parsing work, I would recommend abandoning this project until you do. This is not really something that can or should be explained through a forum.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

problem with cl-who

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

I have installed cl-who and when I am making the test with the code which are in the home page of cl-who, the running return an error.
Code: Select all
(with-html-output (*http-stream*)
  (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
                                ("http://marcusmiller.com/" . "Marcus Miller")
                                ("http://www.milesdavis.com/" . "Miles Davis"))
        do (htm (:a :href link
                  (:b (str title)))
                :br)))



the message error is
Code: Select all
*** - WITH-HTML-OUTPUT: (*HTTP-STREAM*) does not match lambda list element
       (SYSTEM::VAR STREAM &KEY (SYSTEM::DOCTYPE '*WITH-HTML-OUTPUT-DOCTYPE*)
        (SYSTEM::META '(:HTTP-EQUIV "Content-Type" :CONTENT "text/html"))
        SYSTEM::BASE SYSTEM::COMMENT (SYSTEM::TITLE "untitled")
        (SYSTEM::FOOTER T) SYSTEM::HEAD)

djdebaviere
 
Posts: 13
Joined: Fri Dec 04, 2009 1:30 pm

Re: problem with my project in common lisp

Postby nuntius » Wed Dec 23, 2009 10:00 am

From the error message, it looks like you're missing the second parameter in the first list to with-html-output; but the current docs indicate its optional?!?
http://weitz.de/cl-who/#with-html-output
Code: Select all
(with-html-output (*standard-output* nil :prologue t)
    (:html (:body "Not much there"))
    (values))
User avatar
nuntius
 
Posts: 500
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Common Lisp

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

cron