'); /** * H&R 标志 */ public static $HR = array('class="hitandrun"','alt="H&R"','title="H&R"'); /** * 解码后种子列表数组 */ public static $TorrentList = array(); /** * 初始化配置 */ public static function init(){ global $configALL; $config = $configALL[self::SITE]; self::$cookies = $config['cookie']; self::$userAgent = isset($config['userAgent']) && $config['userAgent'] ? $config['userAgent'] : $configALL['default']['userAgent']; self::$passkey = isset($config['passkey']) ? '&passkey='.$config['passkey'].'&https=1' : ''; requests::$input_encoding = self::encoding; //输入的网页编码 requests::$output_encoding = self::encoding; //输出的网页编码 requests::set_cookies(self::$cookies, self::domain); requests::set_useragent([self::$userAgent]); requests::set_timeout([self::CONNECTTIMEOUT,self::TIMEOUT]); } /** * 执行 * * @param string * @return array */ public static function run() { self::init(); Rpc::init(self::SITE, self::METHOD); $html = self::get(); if ( $html === null ) { exit(1); } $data = self::decode($html); Rpc::call($data); exit(0); } /** * 请求页面 * * @param string $url * @return array */ public static function get($url = 'torrents.php') { // 发起请求 $html = requests::get(self::HOST.$url); // 获取列表页数据 $data = selector::select($html, "//*[@class='torrentname']"); if(!$data){ echo "登录信息过期,请重新设置! \n"; return null; } return $data; } /** * 解码 * * @param array $data * @return array */ public static function decode($data = array()) { $downloadStrLen = strlen(self::downloadPrefix); // 前缀长度 $downloadStrEnd = '"'; //种子地址结束标志 $len = $downloadStrLen + 10; // 截取长度 foreach ( $data as $k => $v ){ $arr = array(); // 种子基本信息处理 // 偏移量 $offset = strpos($v,self::downloadPrefix); // 截取 $urlTemp = substr($v,$offset,$len); // 种子地址 $arr['url'] = substr($urlTemp,0,strpos($urlTemp,$downloadStrEnd)); // 种子id $arr['id'] = substr($arr['url'],$downloadStrLen); // 获取主标题 // 偏移量 $h1_offset = strpos($v, '