Skip to content

Instantly share code, notes, and snippets.

View wololock's full-sized avatar
🈷️
https://e.printstacktrace.blog

Szymon Stepniak wololock

🈷️
https://e.printstacktrace.blog
View GitHub Profile
@wololock
wololock / pit_output
Created January 30, 2014 22:38
PIT results for sample TDD exercise project
simons@ideazone-laptop:~/Documents/workspace/idea/tdd-exercise$ mvn pitest:mutationCoverage
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tdd-exercise 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- pitest-maven:0.31:mutationCoverage (default-cli) @ tdd-exercise ---
23:21:58 PIT >> INFO : Mutating from /home/simons/Documents/workspace/idea/tdd-exercise/target/classes
23:21:58 PIT >> INFO : Verbose logging is disabled. If you encounter an problem please enable it before reporting an issue.
@wololock
wololock / gist:621a42546cac6dd0daa2
Created October 7, 2014 19:58
Jsoup select nested li example
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
@Grab(group='org.jsoup', module='jsoup', version='1.8.1')
def html = '''
<div id="something">
<ul>
<li>First element</li>
<li>
@wololock
wololock / gist:719985e6c48f40f8935f
Last active August 29, 2015 14:07
Simple Jsoup skip anchor and empty links example
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
@Grab(group='org.jsoup', module='jsoup', version='1.8.1')
def html = '''
<div id="something">
<a href="#home">This will be skipped</a>
<a href="/page/test#header">This one is ok</a>
<a href="aboutus.html#friends">This is also ok</a>
@wololock
wololock / gist:ade801b2ccf65f21de4d
Last active August 29, 2015 14:07
Selecting last N elements from table rows that match given pattern
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
@Grab(group='org.jsoup', module='jsoup', version='1.8.1')
def html = '''
<table id="test">
<tr>
@wololock
wololock / gist:1a002dfaff5d49d14871
Created October 18, 2014 09:01
Jsoup and ignoring HTTP errors
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
@Grab(group='org.jsoup', module='jsoup', version='1.8.1')
String url = 'http://tomfishburne.com/2014/09/socialmedia.html'
Document document = Jsoup.connect(url)
.userAgent('Mozilla/5.0 (X11; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0')
.ignoreHttpErrors(true)
@wololock
wololock / gist:568b9cc402ea661de546
Created October 18, 2014 09:35
Retrieving table data
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
@Grab(group='org.jsoup', module='jsoup', version='1.8.1')
String url = 'http://www.sportinglife.com/greyhounds/abc-guide'
Document document = Jsoup.connect(url).get()
@wololock
wololock / gist:8ccbc6bbec56ef57fc9e
Created October 18, 2014 09:53
Retrieving table data (Java example)
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JsoupExample {
@wololock
wololock / gist:ffd9ef32f7abe3f325b0
Created October 25, 2014 19:34
Extracting paragraphs from list of link
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class ExtractingParentParagraphsFromScrapedLinks {
public static void main(String[] args) {
String html = "<div class=\"somename\">" +
"<p>This is paragraph with <a href=\"home.html\">link</a>. Lorem ipsum</p>" +
@wololock
wololock / gist:15f511fd9d7da9770f1d
Created October 26, 2014 07:43
Extracting data from rows (Java, Jsoup)
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
public class ExtractingRowFromTableExample {
public static void main(String[] args) throws IOException {
@wololock
wololock / screenshot.groovy
Created November 26, 2014 17:55
How to capture screen with Groovy/Java?
import javax.imageio.ImageIO
import java.awt.Rectangle
import java.awt.Robot
import java.awt.Toolkit
import java.awt.image.BufferedImage
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())
BufferedImage capture = new Robot().createScreenCapture(screenRect)
ImageIO.write(capture, "bmp", new File(args[0]))