1 | lib 1002510 // jsoup |
2 | |
3 | import org.jsoup.*; |
4 | import org.jsoup.nodes.*; |
5 | import org.jsoup.nodes.Document; |
6 | import org.jsoup.nodes.Element; |
7 | import org.jsoup.select.Elements; |
8 | |
9 | static S googleImageSearch_userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"; |
10 | static int googleImageSearch_timeout = 10*1000; |
11 | |
12 | static S googleImageSearch(S q) ctex { |
13 | ret googleImageSearch_elementURL(googleImageSearch_query(q).first()); |
14 | } |
15 | |
16 | static L<S> googleImageSearch_multi(S q) ctex { |
17 | ret map(f googleImageSearch_elementURL, googleImageSearch_query(q)); |
18 | } |
19 | |
20 | static S googleImageSearch_elementURL(Element media) ctex { |
21 | ret htmldecode(media.attr("abs:data-src")); |
22 | } |
23 | |
24 | static Elements googleImageSearch_query(S q) ctex { |
25 | ret googleImageSearch_loadPage(q).select("[data-src]"); |
26 | } |
27 | |
28 | static Document googleImageSearch_loadPage(S q) ctex { |
29 | S googleUrl = "https://www.google.com/search?tbm=isch&q=" + urlencode(q); |
30 | print("Googling " + quote(q)); |
31 | ret Jsoup.connect(googleUrl).userAgent(googleImageSearch_userAgent).timeout(googleImageSearch_timeout).get(); |
32 | } |
Began life as a copy of #1002511
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004999 |
Snippet name: | googleImageSearch |
Eternal ID of this version: | #1004999/8 |
Text MD5: | e56175e95cb0e8699910d922bede0bd2 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-13 00:12:52 |
Source code size: | 1101 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 709 / 902 |
Version history: | 7 change(s) |
Referenced in: | [show references] |