使用POST方法的PHP简单HTML DOM?

时间:2017-12-15 08:44:16

标签: javascript php curl file-get-contents simple-html-dom

如何使用简单的HTML DOM和输入POST方法?

我尝试用cUrl:

$ch = curl_init();
$timeout=5;
$data = array('teks' => '4ia17');
$data=http_build_query($data);
curl_setopt($ch,CURLOPT_URL,"http://baak.gunadarma.ac.id/jadwal/cariJadKul"); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$datas = curl_exec($ch);
curl_close($ch);

echo $datas;

问题是: problem 我也试着这样做

include("simple_html_dom.php");
$request = array(
    'http' => array(
        'header' => array("Content-Type: application/x-www-form-urlencoded"),
        'method' => 'POST',
        'content' => http_build_query(array(
        'teks' => '4ia17'
        )),
    )
);
    $context = stream_context_create($request);
    $htmls = file_get_html("http://baak.gunadarma.ac.id/jadwal/cariJadKul",true, $context);
    echo $htmls; 

,错误是:

  

警告:file_get_contents(http://baak.gunadarma.ac.id/jadwal/cariJadKul):无法打开流:HTTP请求失败!第75行的C:\ xampp \ htdocs \ php-youtube -dl-master \ Downloader \ simple_html_dom.php中的HTTP / 1.1 500内部服务器错误

任何人都可以帮助我,错误在哪里?或者我可以做些什么?

0 个答案:

没有答案