1

我正在为这个问题写信寻求帮助:连接到我们供应商之一的网站并自动下载 PDF 格式的发票。我尝试了几种方法:

1:Webbrowser - 我可以访问带有 pdf 链接的页面,但我无法将它们保存到磁盘(在新窗口中打开)(PDF 是即时生成的,属于这种类型https://www.axxes.fr/it/client/pge1_relevefacturepdf.aspx?selnumdoc=700051126&typ=DUP&lng=ES&famdoc=DUP&typfic=PDF

2:Watin - 我不能像 Webbrowser 那样自动保存 pdf

3:HttpWebRequest - 我无法登录。这是我使用的代码:

public void doSomething()
{
    string post_data = "_cm_url=/it/client/default.aspx&_cm_user=user&_cm_pwd=pwd";
    string uri = "https://www.axxes.fr/it/identification/default.cgi";
    HttpWebRequest request = (HttpWebRequest)
    WebRequest.Create(uri); request.KeepAlive = false;
    request.ProtocolVersion = HttpVersion.Version10;
    request.Method = "POST";
    byte[] postBytes = Encoding.ASCII.GetBytes(post_data);
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = postBytes.Length;
    System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
    Stream requestStream = request.GetRequestStream();
    requestStream.Write(postBytes, 0, postBytes.Length);
    requestStream.Close();
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    listBox1.Text = (new StreamReader(response.GetResponseStream()).ReadToEnd());
    Console.WriteLine(response.StatusCode);
}

public class MyPolicy : ICertificatePolicy
{
    public bool CheckValidationResult(ServicePoint srvPoint,
    X509Certificate certificate, WebRequest request,
    int certificateProblem)
    {
        return true;
    }
}

供应商站点是https://www.axxes.fr/it/ 认证模块是这样的:

<form name="blocident" action="/it/identification/default.cgi" method="POST"> 
<input type="hidden" name="_cm_url" value="/it/client/default.aspx"> 
<div class="e_idlign"> 
 <div class="e_idcol1"> 
  <label for="login" accesskey="2">Login</label> 
  <input type="text" class="e_chp77px" name="_cm_user" id="login">
 </div> 
 <div class="nof"></div> 
 <div class="e_idcol2">
  <label for="password">Password</label> 
  <input type="password" class="e_chp77px" name="_cm_pwd" id="password"> 
 </div> 
</div> 
<div class="e_idlign"> 
 <input type="image" alt="Valider l'identification" src="/it/images/css/env/bt_ok.gif" class="e_btOk" name="btOk"> 
</div> 
<ul id="e_identLien"> 
  <li class="sep">
   <a href="/it/pge1_clientmoralcreation.aspx">Iscriversi</a>
  </li> 
  <li>
   <a href="/it/pge1_question.aspx">Password dimenticata?</a>
  </li> 
</ul>
</form>

我尝试使用 Fiddler 分析导航浏览器的流量,这是因为:

1

POST /it/identification/default.cgi HTTP/1.1
_cm_url=%2Fit%2Fclient%2Fdefault.aspx&_cm_user=user&_cm_pwd=password&btOk.x=23&btOk.y=12

2

GET /it/client/default.aspx HTTP/1.1
ASP.NET_SessionId=3hbcfrzstvxwo145tpgpvmvw
IdSes=4fba1069405c428bab1........

3

GET /it/client/pge1_clientrecherche.aspx HTTP/1.1
ASP.NET_SessionId=3hbcfrzstvxwo145tpgpvmvw
IdSes=4fba1069405c428.............

虽然我发布的代码只是对 CGI 的请求。老实说,我不知道如何访问。好像少了点什么……饼干?如何管理它?你有什么建议吗?

任何想法?再次感谢

4

0 回答 0