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

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

Re: How to get title of web page by url?


From: Thamer Mahmoud
Subject: Re: How to get title of web page by url?
Date: Wed, 28 Jul 2010 21:14:17 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

> (defun www-get-page-title (url)
>   (let ((title))
>     (with-current-buffer (url-retrieve-synchronously url)
>       (goto-char (point-min))
>       (re-search-forward "<title>\\([^<]*\\)</title>" nil t 1)
>       (setq title (match-string 1))
>       (goto-char (point-min))
>       (re-search-forward "charset=\\([-0-9a-zA-Z]*\\)" nil t 1)
>       (decode-coding-string title (intern (match-string 1))))))

Just did a test on a wikipedia page, and looks like
`decode-coding-string' doesn't handle upper-case charsets, like UTF-8,
only utf-8.

So the last line should be:

(decode-coding-string title (intern (downcase (match-string 1)))))))

--
Thamer




reply via email to

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