0

I know this is possible in Perl, but I was wondering if this can be done in PHP.

What I want to do is open a browser with a window, click to a link in that page, or navigate in the browser, then it has a simple textbox called test, and I want to put text in that box then click submit and all done in PHP. I know jQuery and Javascript so I am fine if part of this little project should be done in any of those two. I did some research on it and couldn't find a clear approach to this.

I don't need written code provided for me, I just need an answer with suggestions and if possible, little codes to do some tricks.

Thanks in advance.

-G

4

3 回答 3

0

PHP 是一种服务器端语言,因此一切都在服务器上完成,并将结果发送回用户以在浏览器中显示。你不能在 PHP 中做这样的事情。您最好的选择是使用 javascript 单击页面上的链接并提交表单......但是请解释一下这是为了什么,以便我们可以提供一种方法来做到这一点?

要在 Javascript 中执行此操作,您可以使用 jQuery.click()单击链接并.submit()提交表单。由于表单在第二页,提交代码也必须在该页面上。如果您真的想自动执行此操作,您可以在 iFrame 中加载第一页并使用其中的内容,但两个页面(父页面和 iframe)必须位于同一域中。为了绕过这一点,我会编写一个 Chrome 扩展程序,在这些页面中使用我的 JS(点击/提交内容)插入一个小内容脚本。

在 PHP 中,您可以下载第一个页面,解析您想要从中单击的链接,然后下载该页面,找出其中的表单,然后他们使用 cURL 提交该表单。您也可以使用 cURL 下载页面。这是一个关于如何使用 php 获取远程文件内容的教程。

于 2012-06-12T05:55:08.800 回答
0

PHP 有一个名为的扩展cURL,它能够从 PHP 下载 Web 并访问它或将其保存到磁盘。

要在表单中填写字段,您可能事先知道字段名称和表单操作,并在 cURL 发出的请求中对其进行编码。

文档在这里

希望有帮助!

于 2012-06-12T06:07:12.797 回答
0

您可以使用 curl 在 PHP 中复制表单帖子。这里本身为文本框提供值。php中的导航窗口是我不确定的。

于 2012-06-12T06:00:49.077 回答