Uses 616K of libraries. Click here for Pure Java version (2367L/18K/56K).
!7 lib 1002510 // jsoup import org.jsoup.*; import org.jsoup.nodes.*; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; static S userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"; answer { if (matchStart("show", s, m)) exceptionToUser { S query = m.rest().trim(); if (nempty(query)) ret findImage(query); } } public static String findImage(String question) ctex { ret urlShortener(findImageNoShorten(question)); } public static String findImageNoShorten(String question) ctex { String googleUrl = "https://www.google.com/search?tbm=isch&q=" + urlencode(question); Document doc1 = Jsoup.connect(googleUrl).userAgent(userAgent).timeout(10 * 1000).get(); Element media = doc1.select("[data-src]").first(); String finUrl = media.attr("abs:data-src"); ret htmldecode(finUrl); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, crvwmplrxojx, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002511 |
Snippet name: | Scraping Google Image Search Bot (LIVE) |
Eternal ID of this version: | #1002511/2 |
Text MD5: | 8fdd795ae56fbc3056a23fc9bf8933e1 |
Transpilation MD5: | 432d653efd3d2fe6a78b81a82844f1fc |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-04 00:51:21 |
Source code size: | 890 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 768 / 1494 |
Version history: | 1 change(s) |
Referenced in: | [show references] |