good day. I encountered the following problem, I want to parse the IDs of people when searching on VKontakte, but I don’t give me the whole list of people, why? Here is what I do:

method for sending a request

public string GLOBAL_SEARCH(string from, string to, string city, string country) { //string like = textBox4.Text.Substring(textBox4.Text.IndexOf("wall-", 0)); cook = null; cook = new CookieDictionary(); var request = new HttpRequest(); request.UserAgent = HttpHelper.ChromeUserAgent(); request.Cookies = cook; request.AddParam("al", "1"); request.AddParam("c[age_from]", from); request.AddParam("c[age_to]", to); request.AddParam("c[city]", city); request.AddParam("c[country]", country); request.AddParam("c[name]", "1"); request.AddParam("c[photo]", "1"); request.AddParam("c[section]", "people"); request.AddParam("change", "1"); HttpResponse response = request.Post("http://vk.com/al_search.php"); return response.ToString(); } 

parsing method response received:

 string[] GLOBAL_SEARCH_GO() { string from = (string)numericUpDown1.Value.ToString(); string to = (string)numericUpDown2.Value.ToString(); string city = textBox5.Text; string country = textBox6.Text; List<string> f_list = new List<string>(); var request = new HttpRequest(); request.UserAgent = HttpHelper.ChromeUserAgent(); request.Cookies = cook; Regex newReg = new Regex("<div class=\"labeled name\"><a href=\"/(.*)\" onclick"); while (true) { var z = GLOBAL_SEARCH(from, to, city, country); MatchCollection matches = newReg.Matches(z); if (matches.Count <= 0) break; for (int i = matches.Count - 1, w = 1; i > -1; i--, w++) f_list.Add(matches[i].Groups[1].ToString()); } return f_list.ToArray(); } 

button event:

 private void button7_Click(object sender, EventArgs e) { listBox2.Items.AddRange(GLOBAL_SEARCH_GO()); label11.Text = "Получено: " + listBox2.Items.Count.ToString(); } 

I use xNet library. If anything, authorization is not needed for the search.

  • one
    Why don't you use API? - Ni55aN 5:02 pm
  • @ Ni55aN, because I want to do something like this, programmatically) - inkorpus
  • one
    But this is not necessary. Parsing something that is not intended for parsing is wrong. There is an official API that guarantees the correct answer, and you are trying to pull data from html. Yes, parse it with regulars . - VladD
  • one
    It's like having a number, write it in a string, in Roman numerals, encode, print on paper, and then fax, scan, recognize, decrypt and extract the number from there. - VladD
  • @VladD never liked api) you have no example for my question? - inkorpus

1 answer 1

To the POST request add the parameter offset = 0. And so up to 50. Request details on the parameters

  • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky
  • It is based on the testimony of Sniffer. ) If you catch requests while scrolling, you will see that the offset parameter is added to the POST request. Start from 0 and in steps of 20 to the end pass. And so you can parse up to 1000 Aidi. if your results are more than a thousand, split the request for subqueries. Country, city, gender, age and everything will be fine. - Nikolay
  • Mdu, how not to be perverted - just not to do simply and reliably :) - PinkTux