简体   繁体   English

PHP的另一页上单击按钮

[英]php click button on another page

like in the topic, I want to click a button on a page, which I do not own. 就像主题中一样,我想单击页面上不属于我的按钮。 There are no forms, just a button which I want to click in a time interval like 3 minutes. 没有表单,只有一个按钮,我想在3分钟的时间间隔内单击。

Is it possible? 可能吗?

for example: http://www.google.com click the search button only programmatically by calling a php-script 例如: http : //www.google.com仅通过调用php脚本以编程方式单击搜索按钮

Do you mean actually click that button in user's browser or just perform the same action as if user would click it (for example, get search results in your PHP program)? 您是说实际上是在用户浏览器中单击该按钮,还是只是执行与用户单击该按钮相同的操作(例如,在您的PHP程序中获取搜索结果)?

You definitely cannot do the first as you'll need to use some javascript. 您绝对不能做第一个,因为您需要使用一些javascript。 And in fact even javascript might not be possible due to security restrictions (you can't access a page loaded from different domain). 实际上,由于安全限制,甚至JavaScript也可能无法使用(您无法访问从其他域加载的页面)。

As for simulating the browser in PHP - this is very possible as this is esssentially sending a HTTP request. 至于用PHP模拟浏览器-这很可能,因为这本质上是发送HTTP请求。 You can either build the request yourself and send from PHP to the server using one of socket PHP extensions, curl or fopen wrappper. 您可以自己构建请求,然后使用套接字PHP扩展之一curl或fopen wrappper从PHP发送到服务器。 Or you can use one of several available PHP libraries such as Guzzle ( http://guzzle.readthedocs.org/en/latest/ ) or Symfony BrowserKit ( http://symfony.com/components/BrowserKit ) . 或者,您可以使用几种可用的PHP库之一,例如Guzzle( http://guzzle.readthedocs.org/en/latest/ )或Symfony BrowserKit( http://symfony.com/components/BrowserKit )。

No, that's not possible with PHP. 不,PHP无法实现。 You could try with JS and iFrame or with C#. 您可以尝试使用JS和iFrame或C#。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM