增加封IP检测...

master
j502647092 2015-07-30 18:54:16 +08:00
parent be29882c7d
commit be2b84f56b
4 changed files with 936 additions and 885 deletions

128
Frm_Main.Designer.cs generated
View File

@ -28,15 +28,22 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Frm_Main));
this.SearchView = new System.Windows.Forms.DataGridView();
this.ResultView = new System.Windows.Forms.DataGridView();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.r = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.r = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.r = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.search = new System.Windows.Forms.Button();
this.max = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
@ -48,16 +55,11 @@
this.clearresult = new System.Windows.Forms.Button();
this.clearsearch = new System.Windows.Forms.Button();
this.company = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.keyword = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.s = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.s = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.s = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.keyword = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.r = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.r = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.r = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.sum = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.SearchView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ResultView)).BeginInit();
this.SuspendLayout();
@ -67,11 +69,12 @@
this.SearchView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.SearchView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.company,
this.keyword,
this.s,
this.s,
this.s,
this.keyword});
this.SearchView.Location = new System.Drawing.Point(11, 58);
this.sum});
this.SearchView.Location = new System.Drawing.Point(10, 58);
this.SearchView.Name = "SearchView";
this.SearchView.RowTemplate.Height = 23;
this.SearchView.Size = new System.Drawing.Size(850, 200);
@ -93,6 +96,45 @@
this.ResultView.Size = new System.Drawing.Size(850, 300);
this.ResultView.TabIndex = 1;
//
// 公司名称
//
this..HeaderText = "公司网站";
this..Name = "公司名称";
this..Width = 150;
//
// 关键词
//
this..HeaderText = "关键词";
this..Name = "关键词";
this..Width = 200;
//
// 百度r
//
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.r.DefaultCellStyle = dataGridViewCellStyle5;
this.r.HeaderText = "百度";
this.r.Name = "百度r";
//
// 必应r
//
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.r.DefaultCellStyle = dataGridViewCellStyle6;
this.r.HeaderText = "必应";
this.r.Name = "必应r";
//
// 搜狗r
//
dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.r.DefaultCellStyle = dataGridViewCellStyle7;
this.r.HeaderText = "搜狗";
this.r.Name = "搜狗r";
//
// 查询时间
//
this..HeaderText = "查询时间";
this..Name = "查询时间";
this..Width = 130;
//
// search
//
this.search.Location = new System.Drawing.Point(360, 10);
@ -182,6 +224,12 @@
this.company.Name = "company";
this.company.Width = 150;
//
// keyword
//
this.keyword.HeaderText = "关键词(用英文逗号隔开)";
this.keyword.Name = "keyword";
this.keyword.Width = 330;
//
// 百度s
//
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
@ -206,50 +254,13 @@
this.s.Name = "搜狗s";
this.s.Width = 90;
//
// keyword
//
this.keyword.HeaderText = "关键词(用英文逗号隔开)";
this.keyword.Name = "keyword";
this.keyword.Width = 350;
//
// 公司名称
//
this..HeaderText = "公司网站";
this..Name = "公司名称";
this..Width = 150;
//
// 关键词
//
this..HeaderText = "关键词";
this..Name = "关键词";
this..Width = 200;
//
// 百度r
// sum
//
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.r.DefaultCellStyle = dataGridViewCellStyle4;
this.r.HeaderText = "百度";
this.r.Name = "百度r";
//
// 必应r
//
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.r.DefaultCellStyle = dataGridViewCellStyle5;
this.r.HeaderText = "必应";
this.r.Name = "必应r";
//
// 搜狗r
//
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.r.DefaultCellStyle = dataGridViewCellStyle6;
this.r.HeaderText = "搜狗";
this.r.Name = "搜狗r";
//
// 查询时间
//
this..HeaderText = "查询时间";
this..Name = "查询时间";
this..Width = 130;
this.sum.DefaultCellStyle = dataGridViewCellStyle4;
this.sum.HeaderText = "总计";
this.sum.Name = "sum";
this.sum.Width = 55;
//
// Frm_Main
//
@ -292,17 +303,18 @@
private System.Windows.Forms.SaveFileDialog saveFile;
private System.Windows.Forms.Button clearresult;
private System.Windows.Forms.Button clearsearch;
private System.Windows.Forms.DataGridViewTextBoxColumn company;
private System.Windows.Forms.DataGridViewTextBoxColumn s;
private System.Windows.Forms.DataGridViewTextBoxColumn s;
private System.Windows.Forms.DataGridViewTextBoxColumn s;
private System.Windows.Forms.DataGridViewTextBoxColumn keyword;
private System.Windows.Forms.DataGridViewTextBoxColumn ;
private System.Windows.Forms.DataGridViewTextBoxColumn ;
private System.Windows.Forms.DataGridViewTextBoxColumn r;
private System.Windows.Forms.DataGridViewTextBoxColumn r;
private System.Windows.Forms.DataGridViewTextBoxColumn r;
private System.Windows.Forms.DataGridViewTextBoxColumn ;
private System.Windows.Forms.DataGridViewTextBoxColumn company;
private System.Windows.Forms.DataGridViewTextBoxColumn keyword;
private System.Windows.Forms.DataGridViewTextBoxColumn s;
private System.Windows.Forms.DataGridViewTextBoxColumn s;
private System.Windows.Forms.DataGridViewTextBoxColumn s;
private System.Windows.Forms.DataGridViewTextBoxColumn sum;
}
}

View File

@ -8,6 +8,7 @@ using System.Windows.Forms;
using AliKeywordSearch;
using System.Web;
using System.Reflection;
using System.Text.RegularExpressions;
namespace EnAliKeywordSearch
{
@ -100,7 +101,7 @@ namespace EnAliKeywordSearch
state.Text = "正在 " + s.ToString() + " 查询 " + cpy + " 的关键词 " + key;
for (int i = 1; i <= maxpage; i++)
{
string url = String.Format(UrlEnum.GetUrl(s), HttpUtility.UrlEncode(key), (s.ToString() == "搜狗" ? i : i - 1));
string url = String.Format(UrlEnum.GetUrl(s), HttpUtility.UrlEncode(key), (s.ToString() == "搜狗" ? i : i - 1));//s搜狗的页面值不同
this.ResultView.Rows[index].Cells[s.ToString() + "r"].Value = "查询第" + i + "页...";
Application.DoEvents();
string htmldoc = httpHelper.Get(url);
@ -111,8 +112,28 @@ namespace EnAliKeywordSearch
maybe = true;
continue;
}
string encodecpy = HttpUtility.HtmlEncode(cpy);
if (htmldoc.Contains(encodecpy))
if (htmldoc == "0")
{
this.ResultView.Rows[index].Cells[s.ToString() + "r"].Value = "已被屏蔽";
this.ResultView.Rows[index].Cells[s.ToString() + "r"].Style.ForeColor = Color.Red;
break;
}
string cpyencode = HttpUtility.HtmlEncode(cpy);
int findindex = htmldoc.IndexOf(cpyencode);
if (findindex > 0)
{
string check = htmldoc.Substring(findindex, 60);
while (findindex > 0)
{
check = htmldoc.Substring(findindex, 60);
Console.WriteLine(s.ToString() + " " + i + " " + check);
if (!check.Contains("\\/"))
{
break;
}
findindex = htmldoc.IndexOf(cpyencode, findindex + 1);
}
if ((check.Contains("span") || check.Contains("><") || check.Contains(".html") || check.Contains("href") || check.Contains("%")))
{
pageinfo = "第" + i + "页";
if (i == 1)
@ -120,6 +141,7 @@ namespace EnAliKeywordSearch
this.ResultView.Rows[index].Cells[s.ToString() + "r"].Style.ForeColor = (i == 1 ? Color.Magenta : Color.Black);
break;
}
}
if (i == maxpage)
{
pageinfo = maxpage + "页以后";
@ -132,9 +154,20 @@ namespace EnAliKeywordSearch
this.ResultView.Rows[index].Cells["查询时间"].Value = DateTime.Now.ToString();
Application.DoEvents();
}
Console.WriteLine("==================" + key + "==================");
}
}
if (item.Cells["keyword"].Value != null)
{
if (item.Cells["sum"].Value == null)
item.Cells["sum"].Value = 0;
foreach (SearchType s in Enum.GetValues(typeof(SearchType)))
{
int all = int.Parse(item.Cells["sum"].Value.ToString());
int add = int.Parse(item.Cells[s.ToString() + "s"].Value.ToString());
item.Cells["sum"].Value = all + add;
}
}
Application.DoEvents();
}
state.ForeColor = Color.Green;

View File

@ -120,6 +120,9 @@
<metadata name="company.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="keyword.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="百度s.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -129,7 +132,7 @@
<metadata name="搜狗s.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="keyword.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="sum.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="公司名称.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -85,8 +85,11 @@ namespace EnAliKeywordSearch
args.Referer = "";
args.Cookie = "";
args.Url = "";
args.Accept = "text/html";//,application/xhtml+xml,application/xml,application/json;";
args.UA = "Mozilla/5.0+(Compatible;+Baiduspider/2.0;++http://www.baidu.com/search/spider.html)";
args.Accept = "text/html";//,application/xhtml+xml,application/xml,application/json;"
//args.UA = "Mozilla/5.0+(Compatible;+Baiduspider/2.0;++http://www.baidu.com/search/spider.html)";
//args.UA = @"Mozilla/5.0 (Linux;u;Android 4.2.2;zh-cn;) AppleWebKit/534.46 (KHTML,like Gecko) Version/5.1 Mobile Safari/10600.6.3 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)";
args.UA = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 UBrowser/5.2.2603.31 Safari/537.36";
//http://www.alibaba.com/products/Egg_Laying_Block_Machine/1.html
int iIndex = strUrl.IndexOf(@"//");