修复编码问题 公司名称Html编码 关键词URL编码....

master
j502647092 2015-07-27 16:56:19 +08:00
parent 24f77e9e79
commit 9fc43f81a5
1 changed files with 5 additions and 3 deletions

View File

@ -6,6 +6,7 @@ using System.Drawing;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using AliKeywordSearch; using AliKeywordSearch;
using System.Web;
namespace EnAliKeywordSearch namespace EnAliKeywordSearch
{ {
@ -46,9 +47,10 @@ namespace EnAliKeywordSearch
this.ResultView.Rows[index].Cells["排名"].Value = "正在查询第" + i + "页..."; this.ResultView.Rows[index].Cells["排名"].Value = "正在查询第" + i + "页...";
Application.DoEvents(); Application.DoEvents();
if (enAli.Checked == true) if (enAli.Checked == true)
url = String.Format("http://www.alibaba.com/products/F0/{0}/{1}.html", key, i); url = String.Format("http://www.alibaba.com/products/F0/{0}/{1}.html", HttpUtility.UrlEncode(key), i);
else else
url = String.Format("http://s.1688.com/selloffer/offer_search.htm?keywords={0}&beginPage={1}", key, i); url = String.Format("http://s.1688.com/selloffer/offer_search.htm?keywords={0}&beginPage={1}", HttpUtility.UrlEncode(key), i);
string htmldoc = httpHelper.Get(url); string htmldoc = httpHelper.Get(url);
if (string.IsNullOrEmpty(htmldoc)) if (string.IsNullOrEmpty(htmldoc))
{ {
@ -57,7 +59,7 @@ namespace EnAliKeywordSearch
maybe = true; maybe = true;
continue; continue;
} }
if (htmldoc.Contains(cpy)) if (htmldoc.Contains(HttpUtility.HtmlEncode(cpy)))
{ {
pageinfo = "第" + i + "页"; pageinfo = "第" + i + "页";
break; break;