使用PHP简单的HTML DOM解析器之前登录网站ASP [英] Login to ASP website before using PHP Simple HTML DOM Parser
本文介绍了使用PHP简单的HTML DOM解析器之前登录网站ASP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用PHP简单的HTML DOM解析器来解析从游戏网站的ASP数据。所以我需要的东西,我登录到网站之前开始使用它,我需要获取数据只对注册用户可见。有人建议我一个剧本什么的,它可以做到这一点?非常感谢事先!
I am using "PHP Simple HTML DOM Parser" to parse data from a gaming ASP website. The data that i need to grab are only visible to registered users so i need something to log me in to site before start using it. Can someone suggest me a script or something which it can do this ? Thanks a lot in advance!
推荐答案
首先,你应该张贴有:
<?php
function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
这应该能够发送POST请求。在这之后,你应该能够抓住你所需要的。
That should be able to send a post request. After that, you should be able to grab what you need.
这篇关于使用PHP简单的HTML DOM解析器之前登录网站ASP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文