增加封IP检测...
parent
be29882c7d
commit
be2b84f56b
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
49
Frm_Main.cs
49
Frm_Main.cs
|
@ -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,15 +112,36 @@ namespace EnAliKeywordSearch
|
|||
maybe = true;
|
||||
continue;
|
||||
}
|
||||
string encodecpy = HttpUtility.HtmlEncode(cpy);
|
||||
if (htmldoc.Contains(encodecpy))
|
||||
if (htmldoc == "0")
|
||||
{
|
||||
pageinfo = "第" + i + "页";
|
||||
if (i == 1)
|
||||
item.Cells[s.ToString() + "s"].Value = int.Parse(item.Cells[s.ToString() + "s"].Value.ToString()) + 1;
|
||||
this.ResultView.Rows[index].Cells[s.ToString() + "r"].Style.ForeColor = (i == 1 ? Color.Magenta : Color.Black);
|
||||
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)
|
||||
item.Cells[s.ToString() + "s"].Value = int.Parse(item.Cells[s.ToString() + "s"].Value.ToString()) + 1;
|
||||
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;
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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(@"//");
|
||||
|
|
Loading…
Reference in New Issue