0

我计划创建一个 movil 应用程序(为了好玩),它应该使用这个网页(http://consultawebvehiculos.carabineros.cl/index.php)的结果。有什么方法可以在我的网络代码中创建浏览器实例并读取此结果并使用 Web 服务发布它.. 类似于:

var IE= new broswer("http://consultawebvehiculos.carabineros.cl/index.php");
var result=IE.FindElementByID("txtIdentityCar").WriteText(YourIdentityCar);
publicToWebSerivce(result);

更新:使用 Fiddler 我可以看到 http 帖子是这样的:

POST http://consultawebvehiculos.carabineros.cl/index.php HTTP/1.1
Host: consultawebvehiculos.carabineros.cl
Connection: keep-alive
Content-Length: 61
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://consultawebvehiculos.carabineros.cl
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko)      Chrome/24.0.1312.57 Safari/537.17
Content-Type: application/x-www-form-urlencoded
Referer: http://consultawebvehiculos.carabineros.cl/index.php
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es-ES,es;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

accion=buscar&txtLetras=CL&txtNumeros1=sk&txtNumeros2=12&vin=

可能是我需要一些像 webclient 这样的 .Net 类才能连接到 php 页面……不确定。

更新:我终于找到了使用 Fiddler 来了解总参数的解决方案,并且我使用了来自http://www.hanselman.com/blog/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspx的代码

4

2 回答 2

1

如果您只是对抓取页面感兴趣,我建议使用Html Agility Pack

如果您还想显示页面,则可以使用WebBrowser控件。

于 2013-02-09T03:52:14.377 回答
0

我们一直在使用http://htmlunit.sourceforge.net/来完成类似的任务。它允许您发送请求、接收响应/状态代码/等。

(它是一个 Java 库,因此您可以通过 google 搜索 .Net 端口或使用转换器将 Java 程序集转换为 .Net 程序集 - 请参阅http://blog.stevensanderson.com/2010/03/30/using-htmlunit- on-net-for-headless-browser-automation/用于指导。我们使用了转换方法)。

于 2013-02-09T23:29:21.660 回答