我先用webclient发送如下请求:
http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion=5.0&loc=zh_CN&Requester=UPSHome&tracknum=v0026136576&AgreeToTermsAndConditions=yes&track.x=17&track.y=4
这是一个get请求,可以得到数据,然后要模拟点击上面的详细内容按钮后的结果,我发送如下请求:
http://wwwapps.ups.com/WebTracking/processRequest
参数是:tdmp1=v0026136576          (这个单子号是:v0026136576)
但是得到的结果跟直接点击的不一样,我估计他是用了session,请求解决办法,各位高手多多帮忙啊!

解决方案 »

  1.   

    http://www.cnblogs.com/lovecherry/archive/2005/04/22/143341.html
      

  2.   

    用上面的方法试了,还是不行,我的源代码是这样的,请高手帮忙!
    private void ttt1()
    {
    HttpWebRequest hwr = null;
    Encoding  enc = Encoding.GetEncoding("gb2312"); CookieContainer myCookieContainer=new CookieContainer();  string siteUrl = "http://wwwapps.ups.com/WebTracking/processInputRequest";
    string submitParams = "HTMLVersion=5.0&loc=zh_CN&Requester=UPSHome&tracknum=v0026136576&AgreeToTermsAndConditions=yes&track.x=17&track.y=4";
    submitParams = Regex.Replace(submitParams, @"[\u4e00-\u9fa5]|(|—|)", new MatchEvaluator(MatchEval));

    hwr = (HttpWebRequest)WebRequest.Create(siteUrl +"?" + submitParams);
    hwr.CookieContainer = myCookieContainer;

    hwr.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; HttpWebResponse oResponse  = (HttpWebResponse)hwr.GetResponse();
    oResponse.Cookies = myCookieContainer.GetCookies(hwr.RequestUri); StreamReader sr = new StreamReader(oResponse.GetResponseStream(), enc);
    string outdata = sr.ReadToEnd(); string path = Server.MapPath("admin");
    path += "\\test1.txt"; FileStream fs = new FileStream(path, FileMode.Create);
    StreamWriter sw = new StreamWriter(fs);
    sw.Write(outdata);
    sw.Close();
    fs.Close(); //upsdetail
    hwr = (HttpWebRequest)WebRequest.Create(siteUrl); hwr.CookieContainer = myCookieContainer; hwr.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; hwr.ContentType = "application/x-www-form-urlencoded"; oResponse  = (HttpWebResponse)hwr.GetResponse();
    oResponse.Cookies = myCookieContainer.GetCookies(hwr.RequestUri); sr = new StreamReader(oResponse.GetResponseStream(), enc);
    outdata = sr.ReadToEnd(); path = Server.MapPath("admin");
    path += "\\test2.txt"; fs = new FileStream(path, FileMode.Create);
    sw = new StreamWriter(fs);
    sw.Write(outdata);
    sw.Close();
    fs.Close(); }
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=ATV1GLXT-65FF-4M82-CT5U-B1J65D3ZN2OK