|
03.09.2011, 14:32
|
#1
|
|
|
|
Разведчик
|
Регистрация: 15.07.2011
Сообщений: 1
Популярность: -32
Сказал(а) спасибо: 3
Поблагодарили 0 раз(а) в 0 сообщениях
|
Парсинг ID вконтакте
Вот когда я вставляю код для парсинга ид вконтакте и запускаю прогу у меня чистое окно . Помогите разобратса в чем проблемма . Вот полный код :
Код:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication21
{
public partial class Form1 : Form
{
CookieContainer cookcn = new CookieContainer();
Cookie cook;
string remixsid, pageid;
private void enter_Click(object sender, EventArgs e)
{
string ur = "m=1&email=" + login.Text + "&pass=" + pass.Text;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://vk.com/login.php");
request.UserAgent = "Chrome/13.0";
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.AllowAutoRedirect = false;
byte[] EncodedPostParams = Encoding.GetEncoding(1251).GetBytes(ur);
request.ContentLength = EncodedPostParams.Length;
request.GetRequestStream().Write(EncodedPostParams, 0, EncodedPostParams.Length);
request.GetRequestStream().Close();
string hd = request.GetResponse().Headers.ToString();
Regex sidreg = new Regex("sid=([a-z0-9]+); exp"); Match sidx = sidreg.Match(hd); remixsid = sidx.Groups[1].Value;
cook = new Cookie("remixsid", remixsid); cook.Domain = "vk.com";
Regex pageid1 = new Regex("Location: /id(.*?)\r\n"); Match pageid2 = pageid1.Match(hd); pageid = pageid2.Groups[1].Value;
if (String.IsNullOrEmpty(remixsid) || remixsid == "deleted") { MessageBox.Show("Авторизация провалилась!"); }
else
{
cookcn.Add(cook);
HttpWebRequest Request2 = (HttpWebRequest)System.Net.WebRequest.Create("http://vk.com/id" + pageid);
Request2.CookieContainer = cookcn;
Request2.UserAgent = "Chrome/13.0";
Request2.Method = "GET";
HttpWebResponse Response2 = (HttpWebResponse)Request2.GetResponse();
StreamReader sr1 = new StreamReader(Response2.GetResponseStream(), Encoding.GetEncoding(1251));
string page = sr1.ReadToEnd();
Regex hash1 = new Regex("\"post_hash\": \"(.*?)\""); Match hash2 = hash1.Match(page);
string ur2 = "act=post&al=1&facebook_export=&friends_only=&hash=" + hash2.Groups[1].Value + "&message=Авторизация успешна!¬e_title=&official=&status_export=&to_id=" + pageid + "&type=all";
HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create("http://vk.com/al_friends.php");
request2.CookieContainer = cookcn;
request2.UserAgent = "Chrome/13.0";
request2.Method = "POST";
request2.ContentType = "application/x-www-form-urlencoded";
request2.AllowAutoRedirect = false;
byte[] EncodedPostParams2 = Encoding.GetEncoding(1251).GetBytes(ur2);
request2.ContentLength = EncodedPostParams2.Length;
request2.GetRequestStream().Write(EncodedPostParams2, 0, EncodedPostParams2.Length);
request2.GetRequestStream().Close();
HttpWebResponse response2 = (HttpWebResponse)request2.GetResponse();
InitializeComponent();
}
}
private void pass_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
|
|
|
03.09.2011, 17:44
|
#2
|
|
|
|
Разведчик
|
Регистрация: 01.09.2011
Сообщений: 1
Популярность: 12
Сказал(а) спасибо: 0
Поблагодарили 1 раз в 1 сообщении
|
Re: узнать в чем проблемма
наверное потому что ты что-то покрошил?))
Код:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication21
{
public partial class Form1 : Form
{
CookieContainer cookcn = new CookieContainer();
Cookie cook;
string remixsid, pageid;
public Form1()
{
InitializeComponent();
}
private void enter_Click(object sender, EventArgs e)
{
string ur = "m=1&email=" + login.Text + "&pass=" + pass.Text;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://vk.com/login.php");
request.UserAgent = "Chrome/13.0";
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.AllowAutoRedirect = false;
byte[] EncodedPostParams = Encoding.GetEncoding(1251).GetBytes(ur);
request.ContentLength = EncodedPostParams.Length;
request.GetRequestStream().Write(EncodedPostParams, 0, EncodedPostParams.Length);
request.GetRequestStream().Close();
string hd = request.GetResponse().Headers.ToString();
Regex sidreg = new Regex("sid=([a-z0-9]+); exp"); Match sidx = sidreg.Match(hd); remixsid = sidx.Groups[1].Value;
cook = new Cookie("remixsid", remixsid); cook.Domain = "vk.com";
Regex pageid1 = new Regex("Location: /id(.*?)\r\n"); Match pageid2 = pageid1.Match(hd); pageid = pageid2.Groups[1].Value;
if (String.IsNullOrEmpty(remixsid) || remixsid == "deleted") { MessageBox.Show("Авторизация провалилась!"); }
else
{
cookcn.Add(cook);
HttpWebRequest Request2 = (HttpWebRequest)System.Net.WebRequest.Create("http://vk.com/id" + pageid);
Request2.CookieContainer = cookcn;
Request2.UserAgent = "Chrome/13.0";
Request2.Method = "GET";
HttpWebResponse Response2 = (HttpWebResponse)Request2.GetResponse();
StreamReader sr1 = new StreamReader(Response2.GetResponseStream(), Encoding.GetEncoding(1251));
string page = sr1.ReadToEnd();
Regex hash1 = new Regex("\"post_hash\": \"(.*?)\""); Match hash2 = hash1.Match(page);
string ur2 = "act=post&al=1&facebook_export=&friends_only=&hash=" + hash2.Groups[1].Value + "&message=Авторизация успешна!¬e_title=&official=&status_export=&to_id=" + pageid + "&type=all";
HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create("http://vk.com/al_friends.php");
request2.CookieContainer = cookcn;
request2.UserAgent = "Chrome/13.0";
request2.Method = "POST";
request2.ContentType = "application/x-www-form-urlencoded";
request2.AllowAutoRedirect = false;
byte[] EncodedPostParams2 = Encoding.GetEncoding(1251).GetBytes(ur2);
request2.ContentLength = EncodedPostParams2.Length;
request2.GetRequestStream().Write(EncodedPostParams2, 0, EncodedPostParams2.Length);
request2.GetRequestStream().Close();
HttpWebResponse response2 = (HttpWebResponse)request2.GetResponse();
}
}
private void pass_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
|
|
|
Ваши права в разделе
|
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения
HTML код Выкл.
|
|
|
Похожие темы
|
Тема |
Автор |
Раздел |
Ответов |
Последнее сообщение |
[Помогите!] Парсинг запроса
|
ma_za_xa_ka |
Вопросы и ответы, обсуждения |
4 |
12.12.2011 17:01 |
Парсинг из XML
|
OneShot |
Вопросы и ответы, обсуждения |
13 |
08.12.2011 15:30 |
Парсинг
|
OrBiT_DaRk |
С/С++ |
1 |
20.09.2011 19:14 |
Парсинг.
|
WiLLi-WindowS |
С/С++ |
1 |
01.06.2011 18:07 |
Заявление об ответственности / Список мошенников
Часовой пояс GMT +4, время: 02:47.
|
|