Skip to content

Instantly share code, notes, and snippets.

@wololock
Created October 18, 2014 09:01
Show Gist options
  • Save wololock/1a002dfaff5d49d14871 to your computer and use it in GitHub Desktop.
Save wololock/1a002dfaff5d49d14871 to your computer and use it in GitHub Desktop.
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)
.get()
assert document.body() =~ 'Tom Fishburne: Marketoonist'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment