#region 判断宝贝是否属于淘宝掌柜
ProUrl, 宝贝地址 ShopName 掌柜名
public static string ProIsTaobaoShop(string ProUrl, string ShopName)
{
string istrue = "";
string url = ProUrl;
string htmlString = "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); //声明一个HttpWebRequest请求
request.Timeout = 30000; //设置连接超时时间
request.Headers.Set("Pragma", "no-cache");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream streamReceive = response.GetResponseStream();
Encoding encoding = Encoding.GetEncoding("gb2312");
StreamReader streamReader = new StreamReader(streamReceive, encoding);
htmlString = streamReader.ReadToEnd();//获取搜索页的源码
//Response.Write(htmlString);
streamReader.Close();
streamReceive.Close();
memberinfotaobaobll = new member_info_taobaoBLL();
memberinfotaobaoModel = new member_info_taobao();
memberinfotaobaoModel = memberinfotaobaobll.GetEntity(ShopName);
if (memberinfotaobaoModel!=null && memberinfotaobaoModel.taobaoId!=null)
{
htmlString = htmlString.Substring(htmlString.IndexOf("柜:") + 2, 300);
if (url.IndexOf("detail.tmall.com") != -1)//如果是天猫宝贝
{
int int1 = htmlString.IndexOf(".htm");
int int2 = htmlString.IndexOf("</a>");
htmlString = htmlString.Substring(int1 + 6, int2 - int1).Replace("
", "").Replace("
", "").Replace("</a>", "").Replace(" ", "");
if (htmlString.Length > 1)//如果有找到数据
{
if (htmlString == memberinfotaobaoModel.treasurerNo)
{
istrue = "true";
}
else
{
istrue = "fal";
}
}
else
{
istrue = "fal";
}
}
else if (url.IndexOf("item.taobao.com") != -1)//如果是淘宝宝贝
{
int int1 = htmlString.IndexOf("_blank"");
int int2 = htmlString.IndexOf("</a>");
htmlString = htmlString.Substring(int1 + 8, int2 - int1).Replace("
", "").Replace("
", "").Replace("</a>", "").Replace(" ", "");
if (htmlString.Length > 1)//如果有找到数据
{
if (htmlString == ShopName)
{
istrue = "true";
}
else
{
istrue = "fal";
}
}
else
{
istrue = "fal";
}
}
else
{
istrue = "fal";
}
}
return istrue;
//<label>掌 柜:</label>//天猫掌柜位置
// <div class="right">
// <a href="http://rate.taobao.com/user-rate-UvCNGvm8LMFc0vWTT.htm">贝踏鞋立坊专卖店</a>
// <dt>掌柜:</dt>//淘宝掌柜位置
// <dd>
// <a class="tb-seller-name" href="http://08-08.taobao.com" target="_blank">
// 陈星语2009
// </a>
// </dd>
}
#endregion