douqianrou9079 2015-11-01 21:17
浏览 45

在PHP cURL中提交远程站点的按钮

Is there any way to trigger an onClick event over a button and get the result with cURL PHP or any other method?

<button class="yt-uix-button yt-uix-button-size-small yt-uix-buttondefault business-email-button" type="button" onclick=";return false;">
    <span class="yt-uix-button-content">View email address</span>
</button>
  • 写回答

2条回答 默认 最新

  • duanjia9577 2015-11-01 22:22
    关注

    You cannot directly simulate a click with CURL. You have to analyse the request (HTTP Headers) you send to the server, when you click on the button, with tools like Chrome DevTools. You can use it like this.

    Once you know the request URL and the parameters (if they exist), you can build a CURL request and get the response like this:

    $ch = curl_init();
    
    // params example
    $post = [
        'username' => 'user1',
        'password' => 'pass1'
    ];
    
    // Request URL
    curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    
    // server response
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $server_response = curl_exec ($ch);
    
    curl_close ($ch);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程