package com.statusParser.oldFiles; import java.io.IOException; import org.jsoup.Connection; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; public class vk { public void wallParse(int groupId) { String wallURL = "http://vk.com/wall-" + groupId; try { Document wallDome = Jsoup.connect(wallURL) .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36") .get(); Element date = wallDome.select("div.reply_link_wrap").get(0); String postLink = date.attr("id"); String[] postLastIdString = postLink.split("_"); int postIdCurrent = Integer.parseInt(postLastIdString[2]); String postIdCurrentString; for (int i = 1; i <= 100; i++ ) { postIdCurrentString = Integer.toString(postIdCurrent); Connection.Response response = Jsoup.connect("http://vk.com/wall-" + groupId + "_" + postIdCurrentString) .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36") .timeout(10000) .execute(); if (response.statusCode()== 200){ String Result = postParse(groupId + "_" + postIdCurrentString); if (Result!= null) { System.out.println(Result); } --postIdCurrent; } } } catch (IOException e) { e.printStackTrace(); } } public String postParse(String templateURL) { String postURL = "http://vk.com/wall-" + templateURL; String status = null; try { Document postDom = Jsoup.connect(postURL) .userAgent("Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36") .get(); try { Element text = postDom.select("div.wall_post_text").first(); status = text.text(); } catch (NullPointerException textError) { } } catch (IOException e) { e.printStackTrace(); } return status; } }