Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

27
LINES

< > BotCompany Repo | #1007908 // Google Scraping Test

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 616K of libraries. Click here for Pure Java version (987L/8K/25K).

!7

lib 1002510 // jsoup

import org.jsoup.*;
import org.jsoup.nodes.*;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

p {
  S html = str(googleImageSearch_loadPage("LSD"));
  print(l(html));
  for (L<S> tok : findContainerTag(html, "h3")) {
    print(join(tok));
    print(quote(htmldecode(trim(join(dropAllTags(tok))))));
  }
}

static S googleImageSearch_userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1";
static int googleImageSearch_timeout = 10*1000;

static Document googleImageSearch_loadPage(S q) ctex {
  S googleUrl = "https://www.google.com/search?q=" + urlencode(q);
  print("Googling " + quote(q));
  ret Jsoup.connect(googleUrl).userAgent(googleImageSearch_userAgent).timeout(googleImageSearch_timeout).get();
}

Author comment

Began life as a copy of #1004999

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007908
Snippet name: Google Scraping Test
Eternal ID of this version: #1007908/8
Text MD5: 3e73bc95590f2564fbed9a8137daeea2
Transpilation MD5: 0320f66fa32ab4a8559f7e5626d3b657
Author: stefan
Category: javax / networking
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-16 01:26:22
Source code size: 844 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 425 / 548
Version history: 7 change(s)
Referenced in: [show references]