⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cs

📁 输入网址及资料编号
💻 CS
字号:
/*
 * 自動提取網頁數據
 * Writter:AlfaChiu
 * date: 2008/11/01
 * web: aliado.tw aliado.cc
 * email: alfachiu@gmail.com
 */

using System;
using System.Windows.Forms;
using System.Threading;

using System.IO;
using System.Xml;
using System.Text;
using System.Data;

namespace WebPick
{
    public partial class Main : Form
    {
        public string sql_table;             //資料表名稱
        public string[,] search_key;         //搜尋的關鍵字
        public string[,] sql_table_colume;   //資料表欄位結構
        public string[] str_replace_prifix;  //取回的資料處理前先取代。例如有同名稱的關鍵值abc:abc 123<br>abc 456<br>,取代為:d0 123<br>d1 456<br>
        public string[,] str_replace_subfix; //取回的資料過瀘及替換
        public string str_url_prifix;             //要流覽的網址
        public string str_tbl_start;       //流覽的開始編號
        public string str_tbl_end;         //流覽的結束編號
        public string str_url_subfix;         //要流覽的網址的後端加入的字串
        public string sql_file;            //資料表檔名
		System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
        public Main()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            sql_table = "locales_creature";
            search_key = new string[,]    //50037
            {
                {"http://wowbox.tw/mob.php?wmob=","1","50037",""},
                {"</div><hr><h4>","</h4>","",""},
                {"描述</th>","</td>","",""}
            };
            sql_table_colume = new string[,]
            {
                {"entry",""},{"name_loc5",""},{"subname_loc5",""}
            };
            str_replace_prifix = new string[] { "" };
            str_replace_subfix = new string[,]
            {
                {"<td class='row1'>",""},
                {"<td class='row2'>",""},
                {"<td class='row3'>",""},
                {"<td class='row4'>",""},
                {"<td class='row5'>",""},
                {"<td class='row6'>",""},
                {"&lt;Name&gt;","$N"},
                {"&lt;Class&gt;","$C"},
                {"\r",""},
                {"\n",""},
                {"<br>","\n"},
                {"<br />","\n"},
                {"\n","$B"},
                {"\'","'"},
                {"'","\'"},
                {"\\'","\'"},
            };
            str_url_prifix = search_key[0, 0];
            str_tbl_start = search_key[0, 1];
            str_tbl_end = search_key[0, 2];
            str_url_subfix = search_key[0, 3];
            sql_file = sql_table;

			//////////////////////////////////////////
			DataSet myData = new DataSet();
			//DataRow myRow = new DataRow();

			//////////////////////////////////////////
			this.textBox_url_prifix.Text = str_url_prifix;
            this.label_url_run.Text = str_tbl_start;
            this.textBox_url_subfix.Text = str_url_subfix;

            this.textBox_table.Text = sql_table;
            this.textBox_file.Text = sql_file;

            this.textBox_start.Text = str_tbl_start;
            this.textBox_end.Text = str_tbl_end;

            this.textBox_proc_total.Text = "2";
			/////////////////////////////////////
			//DataTableReader();
			/////////////////////////////////////
			myTimer.Tick += new EventHandler(timer_loop_Tick);
			myTimer.Interval = 2 * 1000;
			//myTimer.Start();
			//CreateNewDataRow();
        }


		private void DataTableReader()
		{
			DataTable table = new DataTable();
			table.ReadXml(@"D:\prog\webpick\Main\bin\Debug\table.xml");
			//DataRow rows = table.Rows[0];

		}
		private void CreateNewDataRow()
		{
			// Use the MakeTable function below to create a new table.
			DataTable table;
			table = MakeNamesTable();

			// Once a table has been created, use the 
			// NewRow to create a DataRow.
			DataRow row;
			row = table.NewRow();

			// Then add the new row to the collection.
			row["sql_table"] = "locales_creature";
			row["sql_table_colume"] = "{\"entry\",\"\"},{\"name_loc5\",\"\"},{\"subname_loc5\",\"\"}";
			table.Rows.Add(row);
			table.WriteXml("table.xml");

		}

		private DataTable MakeNamesTable()
		{
			// Create a new DataTable titled 'Names.'
			DataTable namesTable = new DataTable("locales_creature");

			// Add three column objects to the table.
			DataColumn idColumn = new DataColumn();
			idColumn.DataType = System.Type.GetType("System.Int32");
			idColumn.ColumnName = "id";
			idColumn.AutoIncrement = true;
			namesTable.Columns.Add(idColumn);

			DataColumn fNameColumn = new DataColumn();
			fNameColumn.DataType = System.Type.GetType("System.String");
			fNameColumn.ColumnName = "sql_table";
			fNameColumn.DefaultValue = "sql_table";
			namesTable.Columns.Add(fNameColumn);

			DataColumn lNameColumn = new DataColumn();
			lNameColumn.DataType = System.Type.GetType("System.String");
			lNameColumn.ColumnName = "sql_table_colume";
			namesTable.Columns.Add(lNameColumn);

			// Create an array for DataColumn objects.
			DataColumn[] keys = new DataColumn[1];
			keys[0] = idColumn;
			namesTable.PrimaryKey = keys;

			// Return the new DataTable.
			return namesTable;
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		private void timer_loop_Tick(object sender, System.EventArgs e)
		{
		}
        private void button_enter_Click(object sender, EventArgs e)
        {
            //Int32 totalDiv;
            Int32 start = Convert.ToInt32(this.textBox_start.Text);
            Int32 end = Convert.ToInt32(this.textBox_end.Text);
            Int32 total = Math.Abs(start - end);
            Int32 div = Convert.ToInt32(this.textBox_proc_total.Text);
            Int32 Quotient = total / div;
            Int32 Remainder = total % div;

            Int32 i;
            Browser[] frmRun = new Browser[div];
            if (Quotient < 1)
            {
                div = 1;
            }
            for (i = 0; i < div; i++)
            {
                frmRun[i] = new Browser();
                frmRun[i].sql_table = sql_table;
                frmRun[i].search_key = search_key;
                frmRun[i].sql_table_colume = sql_table_colume;
                frmRun[i].str_replace_prifix = str_replace_prifix;
                frmRun[i].str_replace_subfix = str_replace_subfix;
                frmRun[i].str_url_prifix = str_url_prifix;

                frmRun[i].str_tbl_start = Convert.ToString(start + (i * Quotient));

                if (i == div - 1)
                {
                    frmRun[i].str_tbl_end = Convert.ToString(start + (i * Quotient) + Quotient + Remainder);
                }
                else
                {
                    frmRun[i].str_tbl_end = Convert.ToString(start + (i * Quotient) + Quotient -1);
                }
                frmRun[i].search_key[0, 1] = frmRun[i].str_tbl_start;
                frmRun[i].search_key[0, 2] = frmRun[i].str_tbl_end;

                frmRun[i].str_url_subfix = str_url_subfix;
                frmRun[i].sql_file = frmRun[i].sql_table + "_" + frmRun[i].str_tbl_start + "_" + frmRun[i].str_tbl_end + ".sql";
                frmRun[i].Show();
                Thread.Sleep(500);
            }
        }

		private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
		{
			if(this.WindowState == FormWindowState.Minimized)
			{
				this.WindowState = FormWindowState.Normal;
			}
			else
			{
				this.WindowState = FormWindowState.Minimized;
			}
		}

		private void notifyIcon1_Click(object sender, EventArgs e)
		{
			//this.notifyIcon1.ContextMenu.
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -