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).

1  
!7
2  
3  
lib 1002510 // jsoup
4  
5  
import org.jsoup.*;
6  
import org.jsoup.nodes.*;
7  
import org.jsoup.nodes.Document;
8  
import org.jsoup.nodes.Element;
9  
import org.jsoup.select.Elements;
10  
11  
p {
12  
  S html = str(googleImageSearch_loadPage("LSD"));
13  
  print(l(html));
14  
  for (L<S> tok : findContainerTag(html, "h3")) {
15  
    print(join(tok));
16  
    print(quote(htmldecode(trim(join(dropAllTags(tok))))));
17  
  }
18  
}
19  
20  
static S googleImageSearch_userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1";
21  
static int googleImageSearch_timeout = 10*1000;
22  
23  
static Document googleImageSearch_loadPage(S q) ctex {
24  
  S googleUrl = "https://www.google.com/search?q=" + urlencode(q);
25  
  print("Googling " + quote(q));
26  
  ret Jsoup.connect(googleUrl).userAgent(googleImageSearch_userAgent).timeout(googleImageSearch_timeout).get();
27  
}

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: 491 / 633
Version history: 7 change(s)
Referenced in: [show references]