Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Net;
- using System.Threading.Tasks;
- class Program
- {
- static void Main()
- {
- Console.Write("Username: ");
- string username = Console.ReadLine();
- Console.Write("Password: ");
- string password = Console.ReadLine();
- 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 };
- ServicePointManager.DefaultConnectionLimit = 10;
- var client = new Client();
- var time = new Stopwatch();
- time.Start();
- client.UploadString(
- "http://www.facepunch.com/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=");
- Parallel.ForEach(subforums, subforum =>
- new Client(client.Cookies).DownloadString(new Uri(
- "http://www.facepunch.com/forumdisplay.php?f=" + subforum)));
- time.Stop();
- Console.WriteLine("\nRequest completed in {0} seconds.",
- ((float)time.ElapsedMilliseconds / 1000).ToString("F3"));
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey();
- }
- }
- public class Client : WebClient
- {
- public CookieContainer Cookies { get; private set; }
- public Client(CookieContainer cookies = null)
- {
- Cookies = (cookies != null) ? cookies : new CookieContainer();
- Headers.Add("Content-Type", "application/x-www-form-urlencoded");
- }
- protected override WebRequest GetWebRequest(Uri address)
- {
- WebRequest request = base.GetWebRequest(address);
- HttpWebRequest webRequest = request as HttpWebRequest;
- if (webRequest != null) webRequest.CookieContainer = Cookies;
- return request;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement