org.jsoup.Connection.Method Java Examples

The following examples show how to use org.jsoup.Connection.Method. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpUtil.java    From JsDroidCmd with Mozilla Public License 2.0 6 votes vote down vote up
public static String post(String url, Map<String, String> headers,
		Map<String, String> params) {
	try {
		Connection connect = Jsoup.connect(url);
		connect.ignoreContentType(true);
		connect.ignoreHttpErrors(true);
		if (params != null) {
			connect.data(params);
		}
		if (headers != null) {
			connect.headers(headers);
		}
		connect.method(Method.POST);
		return connect.execute().body();
	} catch (Throwable e) {
	}
	return null;
}
 
Example #2
Source File: ArtStationRipper.java    From ripme with MIT License 6 votes vote down vote up
private JSONObject getJson(URL url) throws IOException {
        Connection con = Http.url(url).method(Method.GET).connection();
        con.ignoreHttpErrors(true);
        con.ignoreContentType(true);
        con.userAgent(
                "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
        con.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
        con.header("Accept-Language", "en-US,en;q=0.5");
//        con.header("Accept-Encoding", "gzip, deflate, br");
        con.header("Upgrade-Insecure-Requests", "1");
        Response res = con.execute();
        int status = res.statusCode();
        if (status / 100 == 2) {
            String jsonString = res.body();
            return new JSONObject(jsonString);
        }
        throw new IOException("Error fetching json. Status code:" + status);
    }
 
Example #3
Source File: TwodgalleriesRipper.java    From ripme with MIT License 6 votes vote down vote up
private void login() throws IOException {
    Response resp = Http.url(this.url).response();
    cookies = resp.cookies();
    String ctoken = resp.parse().select("form > input[name=ctoken]").first().attr("value");

    Map<String,String> postdata = new HashMap<>();
    postdata.put("user[login]", new String(Base64.decode("cmlwbWU=")));
    postdata.put("user[password]", new String(Base64.decode("cmlwcGVy")));
    postdata.put("rememberme", "1");
    postdata.put("ctoken", ctoken);

    resp = Http.url("http://en.2dgalleries.com/account/login")
               .referrer("http://en.2dgalleries.com/")
               .cookies(cookies)
               .data(postdata)
               .method(Method.POST)
               .response();
    cookies = resp.cookies();
}
 
Example #4
Source File: PersonalTest.java    From emotional_analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 抓取个人页面
 * <p>Title: test2</p>
 * <p>Description: </p>
 * @throws Exception
 */
@Test
public void test2() throws Exception{
	System.setProperty("http.maxRedirects", "5000");
	System.getProperties().setProperty("proxySet", "true");
	// 如果不设置,只要代理IP和代理端口正确,此项不设置也可以
	System.getProperties().setProperty("http.proxyHost", "139.224.80.139");
	System.getProperties().setProperty("http.proxyPort", "3128");
	String secKey = new BigInteger(100, new SecureRandom()).toString(32).substring(0, 16);
       String encText = EncryptUtils.aesEncrypt(EncryptUtils.aesEncrypt("{\"uid\":2763211,\"offset\":0,\"limit\":50};","0CoJUm6Qyw8W8jud"), secKey);
       String encSecKey = EncryptUtils.rsaEncrypt(secKey);
    Response execute = Jsoup.connect("http://music.163.com/weapi/user/playlist")
			.data("params",encText)
			.data("encSecKey",encSecKey)
			.method(Method.POST).ignoreContentType(true).execute();
	String string = execute.body().toString();
	System.out.println(string);
}
 
Example #5
Source File: Http.java    From ripme with MIT License 5 votes vote down vote up
private void defaultSettings() {
    this.retries = Utils.getConfigInteger("download.retries", 1);
    connection = Jsoup.connect(this.url);
    connection.userAgent(AbstractRipper.USER_AGENT);
    connection.method(Method.GET);
    connection.timeout(TIMEOUT);
    connection.maxBodySize(0);

    // Extract cookies from config entry:
    // Example config entry:
    // cookies.reddit.com = reddit_session=<value>; other_cookie=<value>
    connection.cookies(cookiesForURL(this.url));
}
 
Example #6
Source File: AmazonLoginApater.java    From crawler-jsoup-maven with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    // grab login form page first
    try {
        
        //lets make data map containing all the parameters and its values found in the form
        Map<String, String> mapParamsData = new HashMap<String, String>();
        mapParamsData.put("email", "[email protected]");
        mapParamsData.put("password", "bluetata");
        
        Response loginResponse = Jsoup.connect("https://passport.jd.com/new/login.aspx")
                .userAgent(USER_AGENT)
                .timeout(TIMEOUT_UNIT * TIMEOUT_TIMES)
                .data(mapParamsData)
                .method(Method.POST)
                .followRedirects(true)
                .execute();
        
        System.out.println("Fetched login page");
        // System.out.println(loginResponse.toString());
        
      //get the cookies from the response, which we will post to the action URL
        Map<String, String> mapLoginPageCookies = loginResponse.cookies();
        
        System.out.println(mapLoginPageCookies);
        
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #7
Source File: WeiboCNLoginApater.java    From crawler-jsoup-maven with Apache License 2.0 5 votes vote down vote up
static Map<String, String> connect() throws IOException {

        // Connection.Response loginForm =
        // Jsoup.connect("https://passport.weibo.cn/signin/login")
        // .method(Connection.Method.GET)
        // .execute();
        //
        // Connection.Response res =
        // Jsoup.connect("https://passport.weibo.cn/signin/login")
        // .data("username", "18241141433", "password", "152300")
        // .data("ec", "0", "entry", "mweibo")
        // .data("mainpageflag", "1", "savestate", "1")
        // .timeout(30 * 1000)
        // .userAgent("Mozilla/5.0")
        // .cookies(loginForm.cookies())
        // .method(Method.POST)
        // .execute();
        // Document doc = res.parse();
        // System.out.println(doc);

        Connection.Response loginForm = Jsoup.connect("https://www.oschina.net/home/login")
                .method(Connection.Method.GET).execute();

        Connection.Response res = Jsoup.connect("https://www.oschina.net/home/login").header("Host", "www.oschina.net")
                .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0")
                .referrer("https://www.oschina.net/home/login")
                .data("username", "[email protected]", "password", "lvmeng152300").data("save_login", "1")
                .timeout(30 * 1000).cookies(loginForm.cookies()).method(Method.POST).execute();
        Document doc = res.parse();
        System.out.println(doc);

        Map<String, String> loginCookies = res.cookies();
        String sessionId = res.cookie("SESSIONID");

        return loginCookies;
    }
 
Example #8
Source File: WeiboCNLoginApater.java    From crawler-jsoup-maven with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {

        try {
            String url = "https://www.oschina.net/home/login";
            String userAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36";

            Connection.Response response = Jsoup.connect(url).userAgent(userAgent).method(Connection.Method.GET)
                    .execute();

            response = Jsoup.connect(url).cookies(response.cookies()).userAgent(userAgent)
                    .referrer("https://www.oschina.net/home/login?goto_page=https%3A%2F%2Fmy.oschina.net%2Fbluetata")
                    .data("username", "[email protected]", "password", "lvmeng152300").data("save_login", "1")
                    .followRedirects(false)
                    .method(Connection.Method.POST).followRedirects(true).timeout(30 * 1000).execute();

            System.err.println(response.statusCode());
            
            Document doc = Jsoup.connect("https://my.oschina.net/bluetata").cookies(response.cookies())
                    .userAgent(userAgent).timeout(30 * 1000).get();

            System.out.println(doc);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
 
Example #9
Source File: FacebookLoginApater.java    From crawler-jsoup-maven with Apache License 2.0 5 votes vote down vote up
static Map<String,String> connect() throws IOException{
    Connection.Response res = Jsoup.connect("https://www.facebook.com/login.php")
            .data("username", "[email protected]", "password", "password")
            .timeout(30 * 1000)
            .userAgent("Mozilla/5.0")
            .method(Method.POST)
            .execute();
    Document doc = res.parse();
    System.out.println(doc);
    
    Map<String, String> loginCookies = res.cookies();
    String sessionId = res.cookie("SESSIONID");
    return loginCookies;
}
 
Example #10
Source File: CommonThread.java    From emotional_analysis with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	
	for(int i = 0;i <= pageSize;i++){
		try{
			String secKey = new BigInteger(100, new SecureRandom()).toString(32).substring(0, 16);//limit
			String encText = EncryptUtils.aesEncrypt(EncryptUtils.aesEncrypt("{\"offset\":"+ i * 10 +",\"limit\":"+(i+1) * 10+"};","0CoJUm6Qyw8W8jud"), secKey);
	        String encSecKey = EncryptUtils.rsaEncrypt(secKey);
		    Response execute = Jsoup.connect("http://music.163.com/weapi/v1/resource/comments/R_SO_4_"+songId)
					.data("params",encText)
					.data("encSecKey",encSecKey)
					.method(Method.POST).ignoreContentType(true).timeout(2000000000).execute();
			String string = execute.body().toString();
			System.out.println(string);
			ObjectMapper objectMapper = new ObjectMapper();
			CommentBean readValue = objectMapper.readValue(string.getBytes(), CommentBean.class);
			long total = readValue.getTotal();
			pageSize = total / 10;
			List<Comments> comments = readValue.getComments();
			for (Comments comments2 : comments) {
				String content = comments2.getContent();
				long time = comments2.getTime();
				User user = comments2.getUser();
				String avatarUrl = user.getAvatarUrl();
				String nickname = user.getNickname();
				long userId = user.getUserId();
				//=========================================数据持久化==========================
				System.out.println("昵称:"+nickname+"评论内容为:"+content+"评论时间为:"+time+"头像地址"+avatarUrl+"用户的ID"+userId);
			}
		}catch(Exception e){
		}
	  }
	}
 
Example #11
Source File: PersonalTest.java    From emotional_analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 个人动态
 * @throws Exception
 */
@Test
public void test3() throws Exception{
	String secKey = new BigInteger(100, new SecureRandom()).toString(32).substring(0, 16);
       String encText = EncryptUtils.aesEncrypt(EncryptUtils.aesEncrypt("{\"uid\":2763211,\"offset\":0,\"limit\":50};","0CoJUm6Qyw8W8jud"), secKey);
       String encSecKey = EncryptUtils.rsaEncrypt(secKey);
    Response execute = Jsoup.connect("http://music.163.com/weapi/event/get/2763211")
			.data("params",encText)
			.data("encSecKey",encSecKey)
			.method(Method.POST).ignoreContentType(true).execute();
	String string = execute.body().toString();
	System.out.println(string);
}
 
Example #12
Source File: FollowerTest.java    From emotional_analysis with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Title: test3</p>
 * <p>Description: </p>
 * @throws Exception 
 */
@Test
public void test3() throws Exception{
		String secKey = new BigInteger(100, new SecureRandom()).toString(32).substring(0, 16);
        String encText = EncryptUtils.aesEncrypt(EncryptUtils.aesEncrypt("{\"offset\":0,\"offset\":0,\"limit\":50};","0CoJUm6Qyw8W8jud"), secKey);
        String encSecKey = EncryptUtils.rsaEncrypt(secKey);
	    Response execute = Jsoup.connect("http://music.163.com/weapi/user/getfollows/380377129")
				.data("params",encText)
				.data("encSecKey",encSecKey)
				.method(Method.POST).ignoreContentType(true).execute();
		String string = execute.body().toString();
		System.out.println(string);
}
 
Example #13
Source File: FollowingTest.java    From emotional_analysis with Apache License 2.0 5 votes vote down vote up
@Test
	public void test3() throws Exception {
		String secKey = new BigInteger(100, new SecureRandom()).toString(32).substring(0, 16);
		String encSecKey = EncryptUtils.rsaEncrypt(secKey);
		String encText = EncryptUtils.aesEncrypt(
				EncryptUtils.aesEncrypt("{\"userId\":63362967,\"offset\":0,\"limit\":100};", "0CoJUm6Qyw8W8jud"),
				secKey);
		Response execute = Jsoup.connect("http://music.163.com/weapi/user/getfolloweds").data("params", encText)
				.data("encSecKey", encSecKey).method(Method.POST).ignoreContentType(true).execute();
//		String string = execute.body().toString();
//		System.out.println(string);
//		System.out.println(string.equals("{\"code\":200,\"more\":false,\"followeds\":[]}"));
//		new FileSourceUtils().importData(string, "follow");
		int i = 0;
		while (true) {
			encText = EncryptUtils.aesEncrypt(
					EncryptUtils.aesEncrypt("{\"userId\":92271210,\"offset\":" + i + ",\"limit\":" + 100 + "};",
							"0CoJUm6Qyw8W8jud"),
					secKey);
			execute = Jsoup.connect("http://music.163.com/weapi/user/getfolloweds").data("params", encText)
					.data("encSecKey", encSecKey).method(Method.POST).ignoreContentType(true).execute();
			String string1 = execute.body().toString();
			if(string1.equals("") || i == 1000){
				break;
			}
			System.out.println(string1);
			new FileSourceUtils().importData(string1,"follow");
			i += 100;
		}
	}
 
Example #14
Source File: IpProxy.java    From emotional_analysis with Apache License 2.0 5 votes vote down vote up
public static List<IpEntity> getProxyIp(String url) throws Exception{
	ArrayList<IpEntity> ipList = new ArrayList<>();
	Response execute = Jsoup.connect(url)
			.header("User-Agent",
					"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36")
			.header("Cache-Control", "max-age=60").header("Accept", "*/*")
			.header("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6").header("Connection", "keep-alive")
			.header("Referer", "http://music.163.com/song?id=186016")
			.header("Origin", "http://music.163.com").header("Host", "music.163.com")
			.header("Content-Type", "application/x-www-form-urlencoded")
			.header("Cookie",
					"UM_distinctid=15e9863cf14335-0a09f939cd2af9-6d1b137c-100200-15e9863cf157f1; vjuids=414b87eb3.15e9863cfc1.0.ec99d6f660d09; _ntes_nnid=4543481cc76ab2fd3110ecaafd5f1288,1505795231854; _ntes_nuid=4543481cc76ab2fd3110ecaafd5f1288; __s_=1; __gads=ID=6cbc4ab41878c6b9:T=1505795247:S=ALNI_MbCe-bAY4kZyMbVKlS4T2BSuY75kw; usertrack=c+xxC1nMphjBCzKpBPJjAg==; NTES_CMT_USER_INFO=100899097%7Cm187****4250%7C%7Cfalse%7CbTE4NzAzNDE0MjUwQDE2My5jb20%3D; [email protected]|1507178162|2|mail163|00&99|CA&1506163335&mail163#hun&430800#10#0#0|187250&1|163|[email protected]; vinfo_n_f_l_n3=8ba0369be425c0d2.1.7.1505795231863.1507950353704.1508150387844; vjlast=1505795232.1508150167.11; Province=0450; City=0454; _ga=GA1.2.1044198758.1506584097; _gid=GA1.2.763458995.1508907342; JSESSIONID-WYYY=Zm%2FnBG6%2B1vb%2BfJp%5CJP8nIyBZQfABmnAiIqMM8fgXABoqI0PdVq%2FpCsSPDROY1APPaZnFgh14pR2pV9E0Vdv2DaO%2BKkifMncYvxRVlOKMEGzq9dTcC%2F0PI07KWacWqGpwO88GviAmX%2BVuDkIVNBEquDrJ4QKhTZ2dzyGD%2Bd2T%2BbiztinJ%3A1508946396692; _iuqxldmzr_=32; playerid=20572717; MUSIC_U=39d0b2b5e15675f10fd5d9c05e8a5d593c61fcb81368d4431bab029c28eff977d4a57de2f409f533b482feaf99a1b61e80836282123441c67df96e4bf32a71bc38be3a5b629323e7bf122d59fa1ed6a2; __remember_me=true; __csrf=2032a8f34f1f92412a49ba3d6f68b2db; __utma=94650624.1044198758.1506584097.1508939111.1508942690.40; __utmb=94650624.20.10.1508942690; __utmc=94650624; __utmz=94650624.1508394258.18.4.utmcsr=xujin.org|utmccn=(referral)|utmcmd=referral|utmcct=/")
			.method(Method.GET).ignoreContentType(true)
			.timeout(2099999999).execute();
	Document pageJson = execute.parse();
	Element body = pageJson.body();
	List<Node> childNodes = body.childNode(11).childNode(3).childNode(5).childNode(1).childNodes();
	//把前10位的代理IP放到List中
	for(int i = 2;i <= 30;i += 2){
		IpEntity ipEntity = new IpEntity();
		Node node = childNodes.get(i);
		List<Node> nodes = node.childNodes();
		String ip = nodes.get(3).childNode(0).toString();
		int port = Integer.parseInt(nodes.get(5).childNode(0).toString());
		ipEntity.setIp(ip);
		ipEntity.setPort(port);
		ipList.add(ipEntity);
	}
	return ipList;
}
 
Example #15
Source File: WebConnector.java    From JavaSkype with MIT License 5 votes vote down vote up
private void updateContacts() throws IOException {
  if (updated) {
    return;
  }
  updated = true;
  String selfResponse = sendRequest(Method.GET, "/users/self/profile").body();
  JSONObject selfJSON = new JSONObject(selfResponse);
  updateUser(selfJSON, false);
  
  String profilesResponse =
          sendRequest(Method.GET, "https://contacts.skype.com/contacts/v2/users/" + getSelfLiveUsername() + "/contacts", true).body();
  try {
    JSONObject json = new JSONObject(profilesResponse);
    if (json.optString("message", null) != null) {
      throw new ParseException("Error while parsing contacts response: " + json.optString("message"));
    }
    JSONArray profilesJSON = json.getJSONArray("contacts");
    for (int i = 0; i < profilesJSON.length(); i++) {
      User user = updateUser(profilesJSON.getJSONObject(i), true);
      if (user != null && !user.getUsername().equalsIgnoreCase("echo123")) {
        skype.addContact(user.getUsername());
      }
    }
  } catch (JSONException e) {
    throw new ParseException(e);
  }
}
 
Example #16
Source File: FuskatorRipper.java    From ripme with MIT License 5 votes vote down vote up
private void getXAuthToken() throws IOException {
    if (cookies == null || cookies.isEmpty()) {
        throw new IOException("Null cookies or no cookies found.");
    }
    Response res = Http.url(xAuthUrl).cookies(cookies).method(Method.POST).response();
    xAuthToken = res.body();
}
 
Example #17
Source File: VkRipper.java    From ripme with MIT License 5 votes vote down vote up
private Map<String,String> getPhotoIDsToURLs(String photoID) throws IOException {
    Map<String,String> photoIDsToURLs = new HashMap<>();
    Map<String,String> postData = new HashMap<>();
    // act=show&al=1&list=album45506334_172415053&module=photos&photo=45506334_304658196
    postData.put("list", getGID(this.url));
    postData.put("act", "show");
    postData.put("al", "1");
    postData.put("module", "photos");
    postData.put("photo", photoID);
    Response res = Jsoup.connect("https://vk.com/al_photos.php")
            .header("Referer", this.url.toExternalForm())
            .header("Accept", "*/*")
            .header("Accept-Language", "en-US,en;q=0.5")
            .header("Content-Type", "application/x-www-form-urlencoded")
            .header("X-Requested-With", "XMLHttpRequest")
            .ignoreContentType(true)
            .userAgent(USER_AGENT)
            .timeout(5000)
            .data(postData)
            .method(Method.POST)
            .execute();
    String jsonString = res.body();
    JSONObject json = new JSONObject(jsonString);
    JSONObject photoObject = findJSONObjectContainingPhotoId(photoID, json);
    String bestSourceUrl = getBestSourceUrl(photoObject);

    if (bestSourceUrl != null) {
        photoIDsToURLs.put(photoID, bestSourceUrl);
    } else {
        LOGGER.error("Could not find image source for " + photoID);
    }

    return photoIDsToURLs;
}
 
Example #18
Source File: WebConnector.java    From JavaSkype with MIT License 5 votes vote down vote up
private Response sendRequest(Method method, String apiPath, boolean absoluteApiPath, String... keyval) throws IOException {
  String url = absoluteApiPath ? apiPath : SERVER_HOSTNAME + apiPath;
  Connection conn = Jsoup.connect(url).maxBodySize(100 * 1024 * 1024).timeout(10000).method(method).ignoreContentType(true).ignoreHttpErrors(true);
  logger.finest("Sending " + method + " request at " + url);
  if (skypeToken != null) {
    conn.header("X-Skypetoken", skypeToken);
  } else {
    logger.fine("No token sent for the request at: " + url);
  }
  conn.data(keyval);
  return conn.execute();
}
 
Example #19
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public void updateUser(User user) throws IOException {
  String reponse = sendRequest(Method.GET, "/users/" + user.getUsername() + "/profile/public", "clientVersion", "0/7.12.0.101/").body();
  JSONObject userJSON = new JSONObject(reponse);
  userJSON.put("username", user.getUsername());
  updateUser(userJSON, false);
}
 
Example #20
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public byte[] getAvatar(User user) throws IOException {
  return sendRequest(Method.GET, user.getAvatarUrl(), true).bodyAsBytes();
}
 
Example #21
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public void removeFromContacts(User user) throws IOException {
  sendRequest(Method.DELETE, "/users/self/contacts/" + user.getUsername());
}
 
Example #22
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public void declineContactRequest(ContactRequest contactRequest) throws IOException {
  sendRequest(Method.PUT, "/users/self/contacts/auth-request/" + contactRequest.getUser().getUsername() + "/decline");
}
 
Example #23
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public void acceptContactRequest(ContactRequest contactRequest) throws IOException {
  sendRequest(Method.PUT, "/users/self/contacts/auth-request/" + contactRequest.getUser().getUsername() + "/accept");
}
 
Example #24
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public void sendContactRequest(User user, String greeting) throws IOException {
  sendRequest(Method.PUT, "/users/self/contacts/auth-request/" + user.getUsername(), "greeting", greeting);
}
 
Example #25
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
private Response sendRequest(Method method, String apiPath, String... keyval) throws IOException {
  return sendRequest(method, apiPath, false, keyval);
}
 
Example #26
Source File: WechatUtil.java    From WechatTestTool with Apache License 2.0 4 votes vote down vote up
/**
 * 得到适合该项目的Connection对象
 */
private static Connection getConn(String url) {
	return Jsoup.connect(url).header("Content-Type", "application/json")
			.ignoreContentType(true).timeout(10000).method(Method.POST);
}
 
Example #27
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public void unblock(User user) throws IOException {
  sendRequest(Method.PUT, "/users/self/contacts/" + user.getUsername() + "/unblock");
}
 
Example #28
Source File: WebConnector.java    From JavaSkype with MIT License 4 votes vote down vote up
public void block(User user) throws IOException {
  sendRequest(Method.PUT, "/users/self/contacts/" + user.getUsername() + "/block", "reporterIp", "127.0.0.1");
}
 
Example #29
Source File: PostSend2.java    From crawler-jsoup-maven with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
        
        String url = "http://jzsc.mohurd.gov.cn/dataservice/query/comp/list";
        Response res = Jsoup.connect(url).execute();
        Map<String, String> cookies = res.cookies();
        System.out.println(cookies);
        
        Map<String, String> datas = new HashMap<>();
        datas.put("$total", "297267");
        datas.put("$reload", "1");
        datas.put("$pg", "31&&1=1");
        datas.put("$pgsz", "15");
        
        Response res1 = Jsoup.connect(url).cookies(cookies).data(datas).method(Method.POST).execute();
        
        String html = res1.body();
        System.out.println(html);
        
//        String jsonBody = "{pg:30,ps:15,tt:297267,pn:5,pc:19818,id:'',st:true}"; 
//        
//        Connection connection = Jsoup.connect("http://jzsc.mohurd.gov.cn/dataservice/query/comp/list")  
//        .userAgent("Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36") // User-Agent of Chrome 55  
//        .referrer("http://jzsc.mohurd.gov.cn/dataservice/query/comp/list")  
//        .header("Content-Type", "application/x-www-form-urlencoded")  
//        .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")  
//        .header("Accept-Encoding", "gzip, deflate")  
//        .header("Accept-Language", "zh-CN,en-US;q=0.8,zh;q=0.6,ja;q=0.4,en;q=0.2")  
//        .header("Cookie", "filter_comp=; JSESSIONID=F53A68FBA45CCF750F9F32ACF090DC9B")  
//        .header("Host", "jzsc.mohurd.gov.cn")  
//        .header("Connection", "keep-alive")  
//        .header("X-Requested-With", "XMLHttpRequest")  
//        .header("Upgrade-Insecure-Requests", "1")  
//        .requestBody(jsonBody)  
//        .maxBodySize(100)  
//        .timeout(1000 * 10)  
//        .method(Connection.Method.POST);  
//  
//        Response response = connection.execute(); 
//        
//        String body = response.body();
//        System.out.println(body);

    }
 
Example #30
Source File: JDLoginApater.java    From crawler-jsoup-maven with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    // grab login form page first
    try {
        
        //lets make data map containing all the parameters and its values found in the form
        Map<String, String> mapParamsData = new HashMap<String, String>();
        mapParamsData.put("loginType", "f");
        mapParamsData.put("loginname", "18241141433");
        mapParamsData.put("nloginpwd", "password");
        mapParamsData.put("eid", "2QE5VJVZUBCRYD7LQZBJBTEFRNKPMQQA5OXKXNY7AAN4A3DKDTR7IN3GXHE5C6B4GTMW3Z53B4RGORB6YG5LUWF2UA");
        mapParamsData.put("fp", "ae5baf289624644fced3f921c6a3792c");
        mapParamsData.put("pubKey", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC7kw8r6tq43pwApYvkJ5laljaN9BZb21TAIfT/vexbobzH7Q8SUdP5uDPXEBKzOjx2L28y7Xs1d9v3tdPfKI2LR7PAzWBmDMn8riHrDDNpUpJnlAGUqJG9ooPn8j7YNpcxCa1iybOlc2kEhmJn5uwoanQq+CA6agNkqly2H4j6wIDAQAB");
        mapParamsData.put("sa_token", "B68C442BE645754F33277E701208059080DD726A94A73F76DEC3053A838549C06EB7D3797CE1C5BBE7C2B2EF9CA7D4676F3D489984B517943EA13575FA80C7E73160F85EDB2705D145C52621D18B86C98B49AAF0DA97A2A7A964A78DDDA048AE592CF17C2AD8BF442AD743460B9316993DCDF5924AD8536FD4392C95A998E1C4C4EEDF76BF8FF03AAC145E449EAB889368EE1E7DA72B18881D527D9F51BAD9E2678DDEAFB33A647DD6D48B2A3BE1BC51DDC55AB1EAAEE2DE9A3CEA3702F93AAD1EC8EF740B632F5A4EC102498CDB31AF91CEA15DB3B6DF6FAC6CA31473ACC5E2CD727F80D2746F504A85379E7F3971086C13BA743F21731CEBFEC558E54E8D5D486CC3A19266E238F539A59C2F8630964981217DCC3B31B324F7DBF41FAEA47CA363904F06816BA9730B31BDD9FFA5498C1D0C36D67F315BA4F9236AC77BAFD5");
        mapParamsData.put("seqSid", "5844668515208615000");
        mapParamsData.put("uuid", "5653262a-5ef1-47c6-8ac2-427f519fdcfa");
        
        Response loginResponse = Jsoup.connect(LOGIN_URI)
                .userAgent(USER_AGENT)
                .timeout(TIMEOUT_UNIT * TIMEOUT_TIMES)
                .data(mapParamsData)
                .method(Method.POST)
                .followRedirects(true)
                .execute();
        
        System.out.println("Fetched login page");
        // System.out.println(loginResponse.toString());
        
      //get the cookies from the response, which we will post to the action URL
        Map<String, String> mapLoginPageCookies = loginResponse.cookies();
        
        System.out.println(mapLoginPageCookies);
        
        Document doc = Jsoup.connect("http://order.jd.com/center/list.action")
                .cookies(mapLoginPageCookies)
                .timeout(30000)
                .get();
        System.out.println(doc.toString());
        
    } catch (Exception e) {
        e.printStackTrace();
    }
}