1 | sS youtubeSearch_userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"; |
2 | |
3 | static int youtubeSearch_timeout = toMS_int(20.0); |
4 | |
5 | static L<Map> youtubeSearch(S q) { |
6 | temp tempLoadingAnim("YouTube search: " + q); |
7 | S pageURL = "https://www.youtube.com/results?search_query=" + urlencode(q); |
8 | S html = loadPageWithUserAgentAndTimeout(pageURL, youtubeSearch_userAgent, youtubeSearch_timeout); |
9 | |
10 | new L<Map> out; |
11 | for (LS ahref : findContainerTag(html, 'a)) { |
12 | continue unless contains(containerTagGet(ahref, 'class), "tile-link"); |
13 | S url = makeAbsoluteURL(pageURL, containerTagGet(ahref, 'href)); |
14 | S text = htmldecode(dropAllTags(join(ahref))); |
15 | out.add(litorderedmap(+url, +text)); |
16 | } |
17 | |
18 | //<a href="/watch?v=CZ9nPidefaQ" class="yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink spf-link " data-sessionlink="itct=CDMQ3DAYEyITCIqQ-srE490CFYnD1QodM6YM1Sj0JFIQaG9sZCBtZSBub3cgc29uZw" title="Thompson Twins - Hold Me Now (Lyrics) [HQ]" aria-describedby="description-id-621161" rel="spf-prefetch" dir="ltr">Thompson Twins - Hold Me Now (Lyrics) [HQ]</a> |
19 | |
20 | ret out; |
21 | } |
Began life as a copy of #1007251
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018454 |
Snippet name: | youtubeSearch [dev.] |
Eternal ID of this version: | #1018454/8 |
Text MD5: | a08377bbb2f3e370cca99af336c5e405 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-30 22:23:13 |
Source code size: | 1151 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 373 / 412 |
Version history: | 7 change(s) |
Referenced in: | [show references] |