Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. reddit.com bot

reddit.com bot

Scheduled Pinned Locked Moved C#
csharpjavascripthtmlcomxml
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yogesh_softworld123
    wrote on last edited by
    #1

    dear sir, i am trying to access reddit.com through c# code. i am using this code: public void Prepare_Url() { try { string response = Send_Request("http://www.reddit.com", null); string postdata ="op=login-main&user=yogeshyahoo&passwd=yogesh&id=%23login_login-main"; response = Send_Request("http://www.reddit.com", postdata); txtResponse.Text = response; } catch (Exception ex) { Console.WriteLine("Exception" + ex.Message); } } public string Send_Request(string link, string post_data) { //try //{ string url = string.Format(link); HttpWebRequest request = (HttpWebRequest )WebRequest.Create(url); request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20"; request.Method = "GET"; request.Accept = "text/xml,application/xml,application/xhtml+xml,text/html,application/json, text/javascript;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; request.KeepAlive = true; request.ContentType = @"application/x-www-form-urlencoded"; request.Referer = string.Format("http://www.reddit.com"); request.CookieContainer = new CookieContainer(); request.CookieContainer.Add(cookies); request.Timeout = 600000; request.AllowAutoRedirect = false; //equest.Credentials = new NetworkCredential("yogeshyahoo","yogesh"); request.PreAuthenticate = true; if (post_data != null) {//post the data to the desired link string postData = post_data; request.Method = "POST"; byte[] postBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(postData); Stream postDataStream = request.GetRequestStream(); postDataStream.Write(postBuffer, 0, postBuffer.Length); postDataStream.Close(); } string s; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); cookies.Add(response.Cookies); E

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups