创建一个“机器人”以填写表单中的某些页面 [英] Creating a 'robot' to fill form with some pages in

查看:102
本文介绍了创建一个“机器人”以填写表单中的某些页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个可以自动填写表格的机器人。
当您可以在页面上填写数据时,例如 form1.html 并提交,等待下一页并在<$ c上提交数据,是否有解决方案$ c> form2.html ,依此类推...
最后,还应该单击按钮以获取表单创建的文件。

I want to implement an 'robot' that could automatically fill forms. Is there an solution when you can fill data on page for example,form1.html and submit it, wait to next page and submit with data on form2.html,and so on... In the end it should also 'click' on a button to get a file that the form creates.

我希望这个机器人使用一些机密信息,所以不能使用客户端技术来完成。

I want this 'robot' would use some confidential information, so it cant be done using client side technologies.

我在考虑 PHP -将其构建为网站Web服务,以便您可以将数据传输到网址,或者 .Net 中的一个Web服务。

I was thinking about PHP - building it as a web site-web service, so you could transfer data to a web address, or a Web Service in .Net.

如果重要的话,我要自动填充的网站是使用 ASP.NET

If it's important,the site I want to fill automatically is runs with ASP.NET.

我在这里提出了新的建议...任何人都可以举一些例子或教程来做这件事。如果存在一些我在这里没有提到的实现它的技术,我也会很乐意尝试它们。

I kind a new here...Can anyone give some examples or tutorials doing this thing. If exist some technologies that I didn't mention here to realize it I would be glad trying them also.

推荐答案

发布数据,因此不必制作一个会在每个字段中键入内容并单击提交的机器人,您只需将数据 POST 发布到服务器即可。

Forms work by posting data, so instead of making a robot that would type something into every field and click submit, you can just POST the data to the server.

首先获取表单字段名称和表单的操作

First grab the form fields names, and the action of the form.

然后使用CURL:

//set POST variables
$url = 'http://domain.com/get-post.php';
$fields = array(
                        'lname' => urlencode($last_name),
                        'fname' => urlencode($first_name),
                        'title' => urlencode($title),
                        'company' => urlencode($institution),
                        'age' => urlencode($age),
                        'email' => urlencode($email),
                        'phone' => urlencode($phone)
                );

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

来自此网站

这篇关于创建一个“机器人”以填写表单中的某些页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆