Skip to content

Instantly share code, notes, and snippets.

@thevuuranusls
Last active November 10, 2015 09:21
Show Gist options
  • Save thevuuranusls/8e9e21c3c772ef76db52 to your computer and use it in GitHub Desktop.
Save thevuuranusls/8e9e21c3c772ef76db52 to your computer and use it in GitHub Desktop.
/**
* hello
*/
package com.tinydream.bigstats.view.test;
import com.gistlabs.mechanize.MechanizeAgent;
import java.io.IOException;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.util.Properties;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
/**
*
* @author macintosh
*/
public class TestJsoup {
public static void main(
String[] args) {
try {
MechanizeAgent agent = new MechanizeAgent();
Properties systemProperties = System.getProperties();
final String host = "proxy.crawlera.com";
final String port = "8010";
systemProperties.setProperty("http.proxyHost", host);
systemProperties.setProperty("http.proxyPort", port);
System.setProperties(systemProperties);
final String authUser = "da4554be5e0d4ab482f0bb5f6fa0f7c7";
final String authPassword = "";
Authenticator.setDefault(
new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
authUser, authPassword.toCharArray());
}
}
);
Document doc = Jsoup.connect("http://whatismyip.org/").get();
System.out.println(doc.toString());
Document doc1 = Jsoup.connect("https://www.facebook.com/hashtag/zingme?page=1").get();
System.out.println(doc1.toString());
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment