mirror of
https://github.com/hakasenyang/osu-tournament-php
synced 2026-08-22 11:13:08 +09:00
include 수정
차후를 위해 spl_autoload_register 사용. 물론 사용 할 만한 클래스가 없지만 그래도...
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @file include/webparser.php
|
||||
* @author Hakase (contact@hakase.kr)
|
||||
*/
|
||||
namespace OsuTournament;
|
||||
class WEBParser
|
||||
{
|
||||
private $httph = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36';
|
||||
public function splits($data, $first, $end, $num = 1)
|
||||
{
|
||||
$temp = @explode($first, $data);
|
||||
$temp = @explode($end, $temp[$num]);
|
||||
$temp = $temp[0];
|
||||
return $temp;
|
||||
}
|
||||
public function WEBParsing($url, $cookie = NULL, $headershow = TRUE, $postparam = NULL, $otherheader = NULL)
|
||||
{
|
||||
$ch = curl_init();
|
||||
$opts = array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
CURLOPT_CONNECTTIMEOUT => 5,
|
||||
CURLOPT_SSL_VERIFYPEER => FALSE,
|
||||
CURLOPT_HEADER => $headershow,
|
||||
CURLOPT_USERAGENT => $this->httph
|
||||
);
|
||||
curl_setopt_array($ch, $opts);
|
||||
if ($otherheader) curl_setopt($ch, CURLOPT_HTTPHEADER, $otherheader);
|
||||
if ($cookie) curl_setopt($ch, CURLOPT_COOKIE, $cookie);
|
||||
if ($postparam)
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postparam);
|
||||
}
|
||||
|
||||
$data = curl_exec($ch);
|
||||
if (curl_errno($ch))
|
||||
return false;
|
||||
curl_close($ch);
|
||||
return ($data) ? $data : false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user