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

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

Re: func return web url content


From: Jai Vetrivelan
Subject: Re: func return web url content
Date: Wed, 11 May 2022 18:25:33 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

On 2022-05-11, 13:57 +0200, Alex <project@gnuhacker.org> wrote:

> 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"
>
> pls help

I tried:

#+BEGIN_SRC elisp
(let ((url-request-method "GET"))
  (url-retrieve "https://gnu.cat/text/rxy.txt";
                (lambda (output)
                  (when-let (err (plist-get output :error))
                        (error "Failed to query: %S" err))
                  (with-current-buffer (current-buffer)
                    (message (buffer-substring (1+ url-http-end-of-headers) 
(point-max)))))))
#+END_SRC

-- 
Jai Vetrivelan



reply via email to

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