* func return web url content @ 2022-05-11 11:57 Alex 2022-05-11 12:32 ` Tassilo Horn 2022-05-11 12:55 ` Jai Vetrivelan 0 siblings, 2 replies; 4+ messages in thread From: Alex @ 2022-05-11 11:57 UTC (permalink / raw) To: Help GNU Emacs 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: func return web url content 2022-05-11 11:57 func return web url content Alex @ 2022-05-11 12:32 ` Tassilo Horn 2022-05-11 15:28 ` GH 2022-05-11 12:55 ` Jai Vetrivelan 1 sibling, 1 reply; 4+ messages in thread From: Tassilo Horn @ 2022-05-11 12:32 UTC (permalink / raw) To: Alex; +Cc: help-gnu-emacs 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: func return web url content 2022-05-11 12:32 ` Tassilo Horn @ 2022-05-11 15:28 ` GH 0 siblings, 0 replies; 4+ messages in thread From: GH @ 2022-05-11 15:28 UTC (permalink / raw) To: Tassilo Horn, help-gnu-emacs Tassilo Horn <tsdh@gnu.org> writes: > Hi Alex, hi tassilo, thanks > (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") works! ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: func return web url content 2022-05-11 11:57 func return web url content Alex 2022-05-11 12:32 ` Tassilo Horn @ 2022-05-11 12:55 ` Jai Vetrivelan 1 sibling, 0 replies; 4+ messages in thread From: Jai Vetrivelan @ 2022-05-11 12:55 UTC (permalink / raw) To: Alex; +Cc: Help GNU Emacs 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-11 15:28 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-05-11 11:57 func return web url content Alex 2022-05-11 12:32 ` Tassilo Horn 2022-05-11 15:28 ` GH 2022-05-11 12:55 ` Jai Vetrivelan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).