Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Net;
- using System.Net.Http;
- using HtmlAgilityPack;
- using System.Text;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- // probably parsing individual post login url...
- // login and generating cookie session
- string loginURL = "https://sas.bpsecure.com/Sas/Authentication/Bigpoint?authUser=22&token=Mv-5JN9U98RwwW_lmo2f9wFwPK-j2IgcwYafVTNOlSpUgZE8uWmiIKefCvKtskeWVAx3bYrK-mRFVHELOnmk3ENN08I0Fh6QEiKKJIB55yJqaKt15kpAzp9gnXVrDmJ37Bnh2d4aVJpTAgtZr6kRFAcMZ0e6dKF9_vA5rpckhimzxKMU2gTeYJjxrrS2rt8wfQtSEmePYx3aM3R_WDncFn1ZTxti5gf3ph89svtr96y1X2vtKR05tL_Px92ypZFoUjB788ioyr52CHXl6C5r8og9CFzES04XVd3LgSaMPvpWxDQMMi4JQCxo8QAloUeU2DN46Bc2WyynI3LMjiEUZtN3fltbc-J9jskl-BvywnZYF5opunqBdFPSyoDaTEbFUluDSZV5WIp27AkbMWexuMdIxmMYIggV-78";
- string loginPostStr = string.Format("username={0}&password={1}", "shotupbro", "kolombo123");
- string loginCookie;
- WebRequest req = WebRequest.Create(loginURL);
- req.ContentType = "application/x-www-form-urlencoded";
- req.Method = "POST";
- byte[] bytes = Encoding.ASCII.GetBytes(loginPostStr);
- req.ContentLength = bytes.Length;
- using (Stream os = req.GetRequestStream())
- {
- os.Write(bytes, 0, bytes.Length);
- }
- WebResponse resp = req.GetResponse();
- loginCookie = resp.Headers["Set-cookie"];
- // working with cookie
- string htmlSource;
- WebRequest getRequest = WebRequest.Create("https://de1.darkorbit.com/indexInternal.es?action=internalStart");
- getRequest.Headers.Add("Cookie", loginCookie);
- WebResponse getResponse = getRequest.GetResponse();
- using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
- {
- htmlSource = sr.ReadToEnd();
- }
- HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
- htmlDocument.LoadHtml(htmlSource);
- var value1 = htmlDocument.DocumentNode.SelectSingleNode("//a[@id='header_uri']");
- Console.WriteLine(htmlSource);
- }
- }
- }
Add Comment
Please, Sign In to add comment