Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Use url-retrieve to fetch weather info #17

Closed
condy0919 opened this issue Mar 15, 2022 · 4 comments · Fixed by #18
Closed

[Feature Request] Use url-retrieve to fetch weather info #17

condy0919 opened this issue Mar 15, 2022 · 4 comments · Fixed by #18

Comments

@condy0919
Copy link

condy0919 commented Mar 15, 2022

No requirement of curl, so it can run on windows out of box.

@josegpt
Copy link
Owner

josegpt commented Mar 15, 2022

Hello Condy0919,

If we would to drop the curl dependency, the capability to fetch multiple cities like this https://wttr.in/{Nuremberg,Hamburg,Berlin}?format=3 will be lost since url-retrieve fetches info as a browser.

Unless we manage fetching multiple cities ourselves; consequently making multiple requests.

I will be taking a look into it.

@condy0919
Copy link
Author

Unless we manage fetching multiple cities ourselves; consequently making multiple requests.

(dolist (city '("Nuremberg" "Hamburg" "Berlin"))
  (url-retrieve (format "https://wttr.in/%s?format=3" city)
                (lambda (_status)
                  (let ((buf (current-buffer))
                        (end (1+ url-http-end-of-headers)))
                    (with-temp-buffer
                      (insert-buffer-substring buf end)
                      (decode-coding-region (point-min) (point-max) 'utf-8)
                      (message "%s" (buffer-string)))))))

Since url-retrieve is async, it can be done in a loop. The same as curl does.

@josegpt
Copy link
Owner

josegpt commented Mar 15, 2022

I created a new pull request removing the curl dependency. Would you like to test it before a merge to main?

@condy0919
Copy link
Author

It works, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants