Jsoup之提交url
生活随笔
收集整理的這篇文章主要介紹了
Jsoup之提交url
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、url提交表單
Map<String, String> map = new HashMap<String, String>();map.put("stuid", "");map.put("pwd", "");//如果有跳轉(302),會自動跳轉Document doc = Jsoup.connect(CommonUrl.Login_URL).data(map).timeout(3000).post();//獲取網頁的標題String title = doc.title();//獲取body中的非格式的內容String body = doc.body().text();修改userAgent
,可以防止在手機上訪問wap網站
conn.userAgent("Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36 SE 2.X MetaSr 1.0");?
?
2、url設置cookie提交
Map<String, String> map = new HashMap<String, String>();map.put("stuid", "");map.put("pwd", "");//建立connectionConnection conn = Jsoup.connect(CommonUrl.Login_URL); //post方法 conn.method(Method.POST); //表單內容 conn.data(map);//Configures the connection to (not) follow server redirects. By default this is true.conn.followRedirects(false); Response response = conn.execute(); //獲取cookieMap<String, String> cookies = response.cookies();Done
轉載于:https://www.cnblogs.com/xingyyy/p/3713335.html
總結
以上是生活随笔為你收集整理的Jsoup之提交url的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【MOSS】Sharepoint大附件上
- 下一篇: [Java,MVC] Eclipse下搭