[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: func return web url content
From: |
Tassilo Horn |
Subject: |
Re: func return web url content |
Date: |
Wed, 11 May 2022 14:32:31 +0200 |
User-agent: |
mu4e 1.7.19; emacs 29.0.50 |
Alex <project@gnuhacker.org> writes:
Hi Alex,
> Hi, I need a function that return an url content.
>
> If GET request to https://gnu.cat/text/rxy.txt return "Hi"
>
> a func like:
>
> (defun wget-req (url)
> (...))
>
> (wget-req "https://gnu.cat/text/rxy.txt") => "Hi"
This would do:
(defun th/url-retrieve-contents (url)
(with-current-buffer (url-retrieve-synchronously url)
(goto-char (point-min))
(when (re-search-forward "\n\n" nil t)
(buffer-substring (point) (point-max)))))
(th/url-retrieve-contents "https://gnu.cat/text/rxy.txt")
Bye,
Tassilo