drxrgundk062317205 2010-07-19 04:11
浏览 33

cURL和SimpleBrowser

I have a script that lets me log into xbox live using simplebrowser. How ever the browser detector on xbox live takes me to a blank page after log in that has an empty form that needs to be submitted. But the form doesn't show on my browser so simplybrowser can't find it to submitted. The creator of the script says I need to use cURL, how can I use curls with simplebrower?

Here's the script.

require_once('simpletest/browser.php');

$browser = new SimpleBrowser();
$browser->get('http://live.xbox.com/en-US/profile/profile.aspx?pp=0&GamerTag=');
$browser->setField('Email Adress', 'blah@blah.com');
$browser->setField('Password', 'blah');
$browser->clickSubmitByName('SI');
$browser->submitFormById('fmHF');
return $browser->getContent();
  • 写回答

1条回答 默认 最新

  • doudaifu6083 2010-07-19 11:10
    关注

    I can help you with just sending form using cURL. View form source and get form action url from <form action="(here)" ...> and put it in $link variable. Every form field put in string with field name and value, like this:

    $postdata = 'EmailAdress=blah@blah.com&Password=blah';
    

    the rest of the script will look like:

    $curl_obj = curl_init();
    curl_setopt($curl_obj, CURLOPT_URL,$link);
    curl_setopt($curl_obj, CURLOPT_TIMEOUT, 20);
    curl_setopt($curl_obj, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($curl_obj, CURLOPT_COOKIESESSION, true);
    curl_setopt($curl_obj, CURLOPT_COOKIEFILE, "cookiefile");
    curl_setopt($curl_obj, CURLOPT_COOKIEJAR, "cookiefile");
    curl_setopt($curl_obj, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl_obj, CURLOPT_POST, 1);
    curl_setopt($curl_obj, CURLOPT_POSTFIELDS, $postdata);
    $response = curl_exec($curl_obj);
    

    in the $response variable will be returned page content. or just return curl_exec($curl_obj);

    评论

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源