本文整理汇总了Java中jodd.http.HttpBrowser类的典型用法代码示例。如果您正苦于以下问题:Java HttpBrowser类的具体用法?Java HttpBrowser怎么用?Java HttpBrowser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpBrowser类属于jodd.http包,在下文中一共展示了HttpBrowser类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import jodd.http.HttpBrowser; //导入依赖的package包/类
public static void test()throws Exception{
HttpBrowser browser = new HttpBrowser();
String url = "http://www.dataoke.com/verify";
HttpRequest httpRequest =HttpRequest.get(url);
httpRequest.header("Host", "www.dataoke.com");
httpRequest.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0");
httpRequest.header("Referer", "http://www.dataoke.com/login?user=reg");
httpRequest.header("Connection", "keep-alive");
httpRequest.header("X-Requested-With", "XMLHttpRequest");
HttpResponse response = browser.sendRequest(httpRequest);
//HttpResponse response = httpRequest.send();
byte[] bs = response.bodyBytes();
TestImage.buff2Image(bs,"d:\\test.jpg");
String vc = "";
String url2 = "http://www.dataoke.com/message?username=15201733862&vc="+vc;
httpRequest = HttpRequest.get(url2);
httpRequest.header("Host", "www.dataoke.com");
httpRequest.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0");
httpRequest.header("Referer", "http://www.dataoke.com/login?user=reg");
httpRequest.header("Connection", "keep-alive");
httpRequest.header("X-Requested-With", "XMLHttpRequest");
response = browser.sendRequest(httpRequest);
String rc = response.body();
System.out.println(rc);
if(rc.contains("1")){
System.out.println("驗證碼輸入正確>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.");
}else{
System.out.println("驗證碼輸入錯誤>>>>>>>>>>>>>>>>>>>>>>>>");
}
}
示例2: getTitle
import jodd.http.HttpBrowser; //导入依赖的package包/类
/**
* getTitle receives a url parameter and return a Response object that hoold the page title
* @param url The HTML page url
* @return Response
*/
static Response getTitle(String url) {
HttpBrowser browser = new HttpBrowser();
HttpRequest request = HttpRequest.get(url);
browser.sendRequest(request);
String page = browser.getPage();
Jerry doc = Jerry.jerry(page);
return new Response(doc.$("title").text());
}
示例3: main
import jodd.http.HttpBrowser; //导入依赖的package包/类
public static void main(String[] args)throws Exception {
Thread.sleep(1000 * 60 * 60);
browser = new HttpBrowser();
executeAll();
// HashSet<Integer> hashSet = new HashSet<Integer>();
// randomSet(0, 400, 50, hashSet);
//System.out.println(hashSet);
//testRandom();
}