首页 » 技术分享 » 之前帮朋友写的一个小工具-征途2新浪卡全自动淘号工具+按钮精灵脚本

之前帮朋友写的一个小工具-征途2新浪卡全自动淘号工具+按钮精灵脚本

 

 

比较简单的小工具

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Text.RegularExpressions;
using System.IO;

namespace Zt2SinaTaoKaTool
{
    public partial class MainForm : Form
    {
        public MainForm()
        {

            InitializeComponent();

        }
        private int ka_ren_count = 10;
        private WebClient client = null;
        private StreamWriter sw = new StreamWriter("ka.txt", true);

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button2.Enabled = true;
            textBox1.Enabled = false;
            try
            {
                ka_ren_count = Int32.Parse(textBox1.Text);
            }
            catch (Exception)
            {
                ka_ren_count = 10;
            }


            //开始任务

            if (client == null)
            {
                client = new WebClient();
            }
            else
            {
                if (client.IsBusy)
                {
                    client.Dispose();
                }
                client = new WebClient();

            }
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            // Add a user agent header in case the 
            // requested URI contains a query.

            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            timer1.Start();
        }
        private int tao_count = 0;
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            MainForm pThis = sender as MainForm;
            if (e.Result != null)
            {
                using (e.Result)
                {

                    StreamReader reader = new StreamReader(e.Result);
                    string s = reader.ReadToEnd();
                    reader.Close();

                    Regex reg = new Regex(@"本组卡号已经被[\d]{0,4}人淘过");
                    Match match = reg.Match(s);
                    if (match.Success)
                    {
                        string value = match.Value;
                        string int_value = value.Replace("本组卡号已经被", "").Replace("人淘过", "").Trim();
                        if (int_value != "")
                        {
                            int ren = Convert.ToInt32(int_value);
                            if (ren <= ka_ren_count)
                            {
                                Regex reg_ka = new Regex("(.){5}-(.){5}-(.){5}-(.){5}");
                                MatchCollection ka_matchs = reg_ka.Matches(s);
                                if (ka_matchs.Count > 0)
                                {
                                    StreamWriter sw_single = new StreamWriter(string.Format("ka_{0}_{1}.txt", DateTime.Now.Ticks, int_value), true);

                                    string _tempLastKa = "";
                                    foreach (Match item in ka_matchs)
                                    {
                                        string _ka = item.Value;
                                        if (_tempLastKa == _ka)
                                        {
                                            continue;
                                        }
                                        _tempLastKa = _ka;
                                        sw.WriteLine(_ka);
                                        sw.Flush();

                                        sw_single.WriteLine(_ka);
                                        listBox1.Items.Add(_ka);
                                    }
                                    sw_single.Close();
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("网络请求出错了,重新打开试试!");
                    }
                }
                tao_count++;
                label2.Text = tao_count.ToString();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            client.OpenReadCompleted -= client_OpenReadCompleted;
            button1.Enabled = true;
            button2.Enabled = false;
            textBox1.Enabled = true;


        }

        private int timer_count = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer_count++;
            label4.Text = timer_count.ToString();
            if (timer_count >= 20)
            {
                timer_count = 0;


                try
                {

                    client.OpenReadAsync(new Uri("http://ka.sina.com.cn/index.php/request/pickNum/gid/722/itemId/3843/1371195204095"), this);

                }
                catch (Exception)
                {

                    MessageBox.Show("网络异常,关了重试!");
                }
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

            //System.Collections.Specialized.StringCollection s = new System.Collections.Specialized.StringCollection();
            //MessageBox.Show(listBox1.SelectedItem as string);
            //s.Add(listBox1.SelectedItem as string);
            Clipboard.SetDataObject(listBox1.SelectedItem as string);

        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            sw.Close();
        }
    }
}

转载自原文链接, 如需删除请联系管理员。

原文链接:之前帮朋友写的一个小工具-征途2新浪卡全自动淘号工具+按钮精灵脚本,转载请注明来源!

0