using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace entropedizer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// A "pre-request," sent to gather SessionID and POST data parameters for the main request
HttpWebRequest prequest = (HttpWebRequest)WebRequest.Create("http://w...content-available-to-author-only...a.info/Chart.aspx?chart=Chart");
HttpWebResponse presponse = (HttpWebResponse)prequest.GetResponse();
Stream pstream = presponse.GetResponseStream();
StreamReader psr = new StreamReader(pstream);
String phtml = psr.ReadToEnd();
Match viewstate = Regex.Match(phtml, "id=\"__VIEWSTATE\".+/>");
Match eventvalidation = Regex.Match(phtml, "id=\"__EVENTVALIDATION\".+/>");
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "__EVENTTARGET=ctl00%24ContentPlaceHolder1%24DG1%24ctl19%24ctl05&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=" + viewstate.ToString().Substring(24, viewstate.Length - 28) + "&__EVENTVALIDATION=" + eventvalidation.ToString().Substring(30, eventvalidation.Length - 34) + "&ctl00%24PlanetList=Entropia+Universe&ctl00%24SearchText=&ctl00%24ContentPlaceHolder1%24CollapsiblePanelExtender3_ClientState=false&ctl00%24ContentPlaceHolder1%24CollapsiblePanelExtender2_ClientState=&ctl00%24ContentPlaceHolder1%24FilterNameDdl=Text&ctl00%24ContentPlaceHolder1%24FilterType=%3D&ctl00%24ContentPlaceHolder1%24FilterName=&ctl00%24ContentPlaceHolder1%24CollapsiblePanelExtender1_ClientState=false&ctl00%24ContentPlaceHolder1%24DG1%24ctl19%24ctl02=1&ctl00%24ContentPlaceHolder1%24DG1%24ctl19%24ctl14=15";
byte[] data = encoding.GetBytes(postData);
// The main request, intended to retreive the desired HTML
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://w...content-available-to-author-only...a.info/Chart.aspx?chart=Chart");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.CookieContainer = new CookieContainer();
Cookie sessionId = new Cookie("ASP.NET_SessionId", Regex.Match(presponse.Headers.ToString(), "ASP.NET_SessionId=.+ d").ToString().Substring(18, Regex.Match(presponse.Headers.ToString(), "ASP.NET_SessionId=.+ d").Length - 21), "/", ".entropedia.info");
sessionId.HttpOnly = true;
request.CookieContainer.Add(new Uri("http://w...content-available-to-author-only...a.info/Chart.aspx?chart=Chart"), sessionId);
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
StreamReader sr = new StreamReader(stream);
textBox1.Text = sr.ReadToEnd();
stream.Close();
sr.Close();
}
}
}