reddit / emacs

Recommended methods of extracting different segments of urls in elisp

ykhurshid · 2022-02-09 12:14
I am wondering if there is a decent way to take a url in Elisp and return different segments of it. My specific use case is that I want to take a invidious video url and return the video id without relying on a regexp monstrosity but such an ability has a lot of applications.
jamesconroyfinn · 2022-02-09 13:36
See https://www.gnu.org/software/emacs/manual/html_mono/url.html
deaddyfreddy · 2022-02-09 13:42
url-generic-parse-url + url-parse-query-string
ykhurshid · 2022-02-09 15:23
Thanks for the help, guys. As always, my inability to properly consult the already included docs outstands me. :p
EndlessApoptosis · 2022-02-10 06:41
Look for ytel on github, it's probably already doing what you are. If it's not then ```url-retrieve-asynchronously``` and then ```libxml-parse-html-...```. After that the DOM of the page is either a returned list or cons cell. To search into it use the ```dom-``` that filter by id, tag, attr, or class. To iterate for multiple results you can use ```mapcar```.
ftrx · 2022-02-10 20:31
You are not alone... IMVHO Emacs do have the best help-system built-in, and one of the least useful help contents inside it... It's very well done both in tool and informative content if you just look for a function/variable/* but to really face broad topic is very messy, with limited content... Mastering Emacs is a very good (e)book but in a more broad sense even in books terms up to date docs are lacking...