当前位置:编程学习 > C/C++ >>

C++提取网页信息

我想做个软件,关于淘宝上面的 ,卖家卖出一个商品会生成一个订单,里面有订单号,商品名称 数量等信息 怎么样提取出来啊
追问:能加下QQ具体说下么  我的是350838600

答案:///   <summary> 
/// 重载GetData函数,多线程调用该函数
/// </summary>
/// <param name= "en "> </param>
public void GetDataOnline()
{
#region 在线程中用到的查询函数
DCurrentState oDCurrentState = new DCurrentState(CurrentState);//声明代理
this.Invoke(oDCurrentState, "Doing ", null);
Thread.Sleep(100);

string en = this.textBox1.Text.ToString();
WebRequest oRequest = WebRequest.Create( " http://dict.cn/search/?q= " + en);
//oRequest.Timeout = 800;超时时间
WebResponse oResponse = oRequest.GetResponse();
Stream oStream = oResponse.GetResponseStream();
StreamReader oReader = new StreamReader(oStream, Encoding.Default);
string oGetData = oReader.ReadToEnd();
string oRegexPat = @ " <big> <font\040size=\ " "2\ " "\040face=\ " "Trebuchet\040MS\ " "> ([\w\W]*?) </big> ";
Regex oRegex = new Regex(oRegexPat, RegexOptions.IgnoreCase);
Match oMatch = oRegex.Match(oGetData);
#endregion

#region 如果匹配成功
if (oMatch.Success)
{
string[] CurrentData = oRegex.Split(oGetData);
if (CurrentData[1].IndexOf( "对不起 ") > = 0 || CurrentData[1].IndexOf( "单词没找到 ") > = 0)
{
//没有查询到该单词
this.Invoke(oDCurrentState, "Failure ", " ");
return;
}
else
{
//查询到有数据,如果自动更新开关为on,
if (this.autoUpdate.Checked)
{
#region 更新本地数据
this.Invoke(oDCurrentState, "Updated ", CurrentData[1].Replace( " <br> ", "\r\n "));
Dict d = new Dict(en);
d._En = en;
d._Cn = CurrentData[1];
d.Update(d);
#endregion
}
else
{
#region 保存结果
this.Invoke(oDCurrentState, "Finish ", CurrentData[1].Replace( " <br> ", "\r\n "));
Dict d = new Dict(en);
d._En = en;
d._Cn = CurrentData[1];

try
{
d.Insert(d);
}
catch (Exception exception)
{

throw exception;
}
finally
{
d = null;
}
#endregion
}
return;
}
}
#endregion
return;

}

上一个:关于C++编程
下一个:c++程序改错

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,