Please , I need a help...I have to make a webgrabber in scheme language(quite the same as Lisp, as you sure know)..so if someone could help me finding idea for that..THANX..
It should just take a look at a web page (choosen in the programme), and read it...then I d like to display the result, and see all the links that are on the page(and of course going to these pages linked)...but, stop the linkage after three links overviewed...That s all...it shouldn t be complicated, but I have difficulties to find the main idea for that programm.....
Please, answer me(before about 3 or 4 days), by e mail or directly in that newsgroup....THANX VERY MUCH
······@efrei.fr (Michael Breion) writes:
< Please , I need a help...I have to make a webgrabber in scheme
< language(quite the same as Lisp, as you sure know)..so if someone
< could help me finding idea for that..THANX..
< It should just take a look at a web page (choosen in the programme),
< and read it...then I d like to display the result, and see all the
< links that are on the page(and of course going to these pages
< linked)...but, stop the linkage after three links overviewed...That
< s all...it shouldn t be complicated, but I have difficulties to find
< the main idea for that programm.....
< Please, answer me(before about 3 or 4 days), by e mail or directly
< in that newsgroup....THANX VERY MUCH
Here is a simple example of how to download a web page with acl 5.0.
If you need a parser for hypertext I think that you can get one in the
closure web browser (don't have a url handy, sorry).
;;;; -*-Mode: common-lisp; Package: user; -*-
;;;; June 07, 1999 Monday 2:05 PM
;;;; Sockets
(in-package :user)
(defmacro with-open-socket ((var-name &rest options) &body forms)
;; Can't believe this isn't defined - I may be overlooking
;; something, but this should suffice.
`(let ((,var-name (socket:make-socket ,@ options)))
(unwind-protect
(locally ,@ forms)
(close ,var-name))))
(defmacro with-inet-socket ((var-name host &rest options) &body forms)
`(with-open-socket (,var-name
:address-family :internet
:remote-host ,host
:remote-port "http"
:type :stream ,@options)
,@ forms))
(defun socket-terpri (stream &optional terminating-p)
(write-char #\Return stream)
(write-char #\Newline stream)
(when terminating-p
(write-char #\Return stream)
(write-char #\Newline stream)))
(defun print-webpage (&optional (page "www.yahoo.com"))
(with-inet-socket (s page)
(write-string "GET / HTTP 1.0" s)
(socket-terpri s nil)
(write-string "Accept: text/html")
(socket-terpri s nil)
(write-string "User-Agent: Internet Explorer")
(socket-terpri s t)
(force-output s)
(loop for line = (read-line s nil)
while line do (write-line line))))
You can now do (print-webpage "www.yahoo.com"). This is probably not
the best method, but it should help get you going.