Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Net;
- using System.Threading.Tasks;
- class Program
- {
- static void Main()
- {
- ServicePointManager.DefaultConnectionLimit = 100;
- var stopwatch = new Stopwatch();
- stopwatch.Start();
- Console.Write("Username: ");
- string username = Console.ReadLine();
- Console.Write("Password: ");
- string password = Console.ReadLine();
- var client = new Client();
- client.Post("login.php?do=login",
- (
- "vb_login_username=" + username +
- "&vb_login_password_hint=Password" +
- "&vb_login_password=" + password +
- "&s=" +
- "&cookieuser=1" +
- "&securitytoken=guest" +
- "&do=login" +
- "&vb_login_md5password=" +
- "&vb_login_md5password_utf="
- ));
- string folder = Environment.GetFolderPath(
- Environment.SpecialFolder.Desktop) + @"\Session\";
- if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
- int[] subforums =
- {
- 6, 15, 16, 36, 38, /*40,*/ 46, 51, 56, 60, 62, 64, 65, 66, 75, 76,
- 107, 110, 189, 198, 240, 243, 262, 277, 315, 316, 339, 353, 361,
- 383, 384, 385, 389, 391, 393, 394, 396, 397, 401, 403, 408, 409,
- 411, 412, 414, 415
- };
- Parallel.ForEach(subforums, subforum =>
- {
- client.Get("forumdisplay.php?f=" + subforum);
- File.WriteAllText(folder + subforum + ".htm", client.Page);
- });
- stopwatch.Stop();
- Console.WriteLine("\nSubforums fetched in {0} seconds",
- (float)stopwatch.ElapsedMilliseconds / 1000);
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey();
- }
- }
- class Client
- {
- public HttpStatusCode Code { get; private set; }
- public string Page { get; private set; }
- private CookieContainer _Cookies = new CookieContainer();
- public void Get(string path = null)
- { Update(false, path, null); }
- public void Post(string path = null, string param = null)
- { Update(true, path, param); }
- private void Update(bool post, string path, string param)
- {
- var request = (HttpWebRequest)WebRequest.
- Create("http://www.facepunch.com/" + path);
- request.CookieContainer = _Cookies;
- request.Proxy = null;
- if (post)
- {
- request.ContentLength = param.Length;
- request.ContentType = "application/x-www-form-urlencoded";
- request.Method = "POST";
- using (var writer = new StreamWriter(request.GetRequestStream()))
- writer.Write(param);
- }
- using (var response = (HttpWebResponse)request.GetResponse())
- using (var reader = new StreamReader(response.GetResponseStream()))
- {
- Page = reader.ReadToEnd();
- Code = response.StatusCode;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement