我正在使用“PHP Simple HTML DOM Parser”来解析来自游戏 ASP 网站的数据。我需要抓取的数据仅对注册用户可见,所以我需要一些东西让我在开始使用它之前登录到站点。有人可以建议我一个脚本或可以做到这一点的东西吗?提前非常感谢!
问问题
1823 次
1 回答
0
First, you should post with:
<?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;
}
That should be able to send a post request. After that, you should be able to grab what you need.
于 2013-01-01T19:14:34.903 回答