help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Retrieve a web page into buffer and insert some text into it.


From: ken
Subject: Retrieve a web page into buffer and insert some text into it.
Date: Wed, 28 Jul 2010 11:36:19 -0400
User-agent: Thunderbird 2.0.0.24 (X11/20100721)

How would I fetch a web page into a new buffer, then programmatically
insert some text into it?  (Of course subsequently saving the buffer to
a file may done interactively.)

I know a little elisp, but not yet the polished programmer (as this
nonfunctioning code shows):

load url.el

(defun www-edit-web-page (url)
  "Retrieve web page and load into new buffer for editing.
Automatically insert after <body> tag URL, appropriately html-tagged URL."
  (interactive "sLoad URL: "
  (with-temp-buffer (url-retrieve url edit-web-page))))


(defun edit-web-page (status)
      "Switch to the buffer returned by `url-retreive'.
    The buffer should contain the web page sent by the server."
      (switch-to-buffer (current-buffer))
    (goto-char 0)
    (re-search-forward "<body.*>" nil t) ;go to end of <body ...> tag.
    ;insert URL into page, properly html-coded.
    (insert "\n<p>From: <a href=\"" url "\">" url "</a>\n </p>\n\n"))




-- 
Find research and analysis on US healthcare, health insurance,
and health policy at: <http://healthpolicydaily.blogspot.com/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]