用WebRequest POST 方式投票

rusli
Site Admin
文章: 212
註冊時間: 週三 7月 07, 2010 9:49 pm

用WebRequest POST 方式投票

文章rusli » 週一 2月 21, 2011 12:19 am

執行一次會幫你灌兩千個票數

[目的]
幫朋友投票票數

[技術]
用WebRequest POST 方式投票

代碼: 選擇全部


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <!--姓名-->
    <add key="YOUR_NAME" value="Rusli"/>
    <!--電話-->
    <add key="YOUR_PHONE" value="091XXXXXX1"/>

    <!-- 不可變動 -->
    <add key="YOUR_VOTEWEB" value="http://www.XXXXXXXXXXXX.com.tw/XXXXXXXXXX/voting.aspx?id=XXX"/>
    <add key="VIEWSTATE" value="%2fwEPDwULLTEzMjAwNTEzNzZkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQ9JbWFnZUJ1dHRvblZvdGWgP%2f8X1uxShdeg7%2f%2br2X7nY%2bytVA%3d%3d"/>
    <add key="EVENTVALIDATION" value="%2fwEWBQL%2fqtyCDAKs7ZrlDALxyNnJAwKfoPPkBgKH1KKUBRhC27A5bI47MZLnMh8GFnd5hMDT"/>
    <!-- 會幫你 跑 rusli0@mail.rusli.idv.tw ~ rusli1999@mail.rusli.idv.tw -->
    <add key="YOUR_EMAIL" value="rusli{0}@mail.rusli.idv.tw"/>
  </appSettings>
</configuration>





代碼: 選擇全部


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
 
namespace VoteApps
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 2000; i++)
            {
                string outputMsg = string.Empty;
                outputMsg = string.Format(System.Configuration.ConfigurationManager.AppSettings["YOUR_EMAIL"], i);
                // Create a request using a URL that can receive a post.
                WebRequest request = WebRequest.Create(System.Configuration.ConfigurationManager.AppSettings["YOUR_VOTEWEB"]);
                // Set the Method property of the request to POST.
                request.Method = "POST";

                string VIEWSTATE = System.Configuration.ConfigurationManager.AppSettings["VIEWSTATE"];
                string EVENTVALIDATION = System.Configuration.ConfigurationManager.AppSettings["EVENTVALIDATION"];

                string YOUR_NAME = System.Configuration.ConfigurationManager.AppSettings["YOUR_NAME"];
                string YOUR_PHONE = System.Configuration.ConfigurationManager.AppSettings["YOUR_PHONE"];

                // Create POST data and convert it to a byte array.
                string postData = "__VIEWSTATE={0}&__EVENTVALIDATION={1}&TextBoxVotename={2}&TextBoxVotetel={3}&TextBoxVotemail={4}&ImageButtonVote.x=69&ImageButtonVote.y=21";
                postData = string.Format(postData, VIEWSTATE, EVENTVALIDATION, YOUR_NAME, YOUR_PHONE, outputMsg);

                byte[] byteArray = Encoding.UTF8.GetBytes(postData);

                // Set the ContentType property of the WebRequest.
                request.ContentType = "application/x-www-form-urlencoded";
                // Set the ContentLength property of the WebRequest.
                request.ContentLength = byteArray.Length;
                // Get the request stream.
                Stream dataStream = request.GetRequestStream();
                // Write the data to the request stream.
                dataStream.Write(byteArray, 0, byteArray.Length);
                // Close the Stream object.
                dataStream.Close();
                // Get the response.
                WebResponse response = request.GetResponse();
                // Display the status.
                //Console.WriteLine(((HttpWebResponse)response).StatusDescription);
                // Get the stream containing content returned by the server.
                dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                if (responseFromServer.IndexOf("同個作品,一個email一天只能投一票!") > -1)
                {
                    outputMsg += " fail! 同個作品,一個email一天只能投一票!";
                }
                else
                {
                    outputMsg += " ok!";
                }

                // Clean up the streams.
                reader.Close();
                dataStream.Close();
                response.Close();

                Console.WriteLine(outputMsg);
            }
            Console.ReadLine();
        }
    }
}



回到「C#」

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客