package com.statusParser.oldFiles; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class vkOld { private String statuses[] = new String[9]; public void wallParse(int id) { int iteration = 4; while (1==1) { String statuses[] = (vkPart(id, iteration)); if (statuses[0] == null && statuses[1] == null && statuses[2] == null && statuses[3] == null && statuses[4] == null && statuses[5] == null && statuses[6] == null && statuses[7] == null) { break; } iteration++; } } private static String getUrlSource(String url) throws IOException { URL yahoo = new URL(url); URLConnection yc = yahoo.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader( yc.getInputStream(), "windows-1251")); String inputLine; StringBuilder a = new StringBuilder(); while ((inputLine = in.readLine()) != null) a.append(inputLine); in.close(); return a.toString(); } public String[] vkPart(int id, int firstPost) { for (int i=0;i<8;i++) { statuses[i] = null; } int iter = 0; String partURL = "http://vk.com/al_wall.php?act=get_wall&al=1&fixed=&offset=" + firstPost + "&owner_id=-" + id + "&type=all"; try { String partSource = getUrlSource(partURL); partSource = partSource.substring(4); Document partDom = Jsoup.parse(partSource); try { Elements postTexts = partDom.select("div.wall_post_text"); for (Element postText : postTexts) { statuses[iter] = postText.text(); iter++; System.out.println(statuses[iter]); } } catch (NullPointerException eText) { eText.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } return statuses; } }