解决云帆小说下载阅读器不能下载https网址的问题

解决思路:通过本地PHP环境,把目录页抓取并显示出来,
1、index.php源码如下

<?php
#小说目录页网址
$url = "https://www.cccc";


$UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$curl = curl_init();	//创建一个新的CURL资源
curl_setopt($curl, CURLOPT_URL, $url);	//设置URL和相应的选项
curl_setopt($curl, CURLOPT_HEADER, 0);  //0表示不输出Header,1表示输出
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);	//设定是否显示头信息,1显示,0不显示。
//如果成功只将结果返回,不自动输出任何内容。如果失败返回FALSE
 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_ENCODING, '');	//设置编码格式,为空表示支持所有格式的编码
//header中“Accept-Encoding: ”部分的内容,支持的编码格式为:"identity","deflate","gzip"。
 
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
//设置这个选项为一个非零值(象 “Location: “)的头,服务器会把它当做HTTP头的一部分发送(注意这是递归的,PHP将发送形如 “Location: “的头)。
 
$html = curl_exec($curl);
//$html = mb_convert_encoding($html ,'utf-8' , 'gbk');
function characet($data){
  if( !empty($data) ){
    $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
    if( $fileType != 'UTF-8'){
      $data = mb_convert_encoding($data ,'utf-8' , $fileType);
    }
  }
  return $data;
}
$html=characet($html);

#目录页过滤,输入开始和结束标记
$info['area_start']='<div id="readerlist">';
$info['area_end']='<div class="all_ad clearfix mtop"';



//$html = file_get_contents($url);
//$html = str_replace("href=\"/","href=\"ny.php?url=https://www.biqudao.com/",$html);
$html = str_replace('href="','href="ny.php?url=',$html);


function return_preg_match($pattern, $content, $reg_key = 'content') {
        if (is_array($pattern)) {
            foreach ($pattern as $patt) {
                if (preg_match('/' . $patt . '/i', $content, $cont)) {
                    $cont = $cont[$reg_key];
                    break;
                } else {
                    $cont = false;
                } 
            } 
        } else {
            if (preg_match('/' . $pattern . '/i', $content, $cont)) {
                //$cont = $cont['match'];
            } else {
                $cont = false;
            } 
        } 
        return empty($cont)?'':$cont;
    } 
	
	
	

   
       if (!empty($info['area_start']) || !empty($info['area_end'])) {
            $newConfig['reg_source_cont'] = $info['area_start'] . (!empty($info['area_end']) ? '(?P<match>[\s\S]+?)' : '(?P<match>[\s\S]+)') . $info['area_end'];
            $newConfig['reg_source_cont'] = str_replace ('(*)', '[\s\S]*?', $newConfig['reg_source_cont']);
            $newConfig['reg_source_cont'] = preg_replace ('/\\\*([\'\/])/', "\\\\$1", $newConfig['reg_source_cont']);
			
			        $zzb= $newConfig['reg_source_cont'];

					$zhengwen= return_preg_match($zzb,$html);
					if (isset($zhengwen['match'])){
					$zhengwen= $zhengwen['match'];
					}else{
						echo '规则可能不对';
					}
			echo $zhengwen;
			
        }else{
			echo $html;
		}


//echo $html;
 
?>

2、ny.php源码如下

<?php
#小说目录页链接网址补全
$base_url = 'https://www.bqg5200.com/';
#内页过滤,输入开始和结束标记
$info['area_start']='<div id="content">';
$info['area_end']='<div class="adsgg">';
$cj=0;

$url = $base_url.$_GET["url"];

$UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$curl = curl_init();	//创建一个新的CURL资源
curl_setopt($curl, CURLOPT_URL, $url);	//设置URL和相应的选项
curl_setopt($curl, CURLOPT_HEADER, 0);  //0表示不输出Header,1表示输出
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);	//设定是否显示头信息,1显示,0不显示。
//如果成功只将结果返回,不自动输出任何内容。如果失败返回FALSE
 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_ENCODING, '');	//设置编码格式,为空表示支持所有格式的编码
//header中“Accept-Encoding: ”部分的内容,支持的编码格式为:"identity","deflate","gzip"。
 
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
//设置这个选项为一个非零值(象 “Location: “)的头,服务器会把它当做HTTP头的一部分发送(注意这是递归的,PHP将发送形如 “Location: “的头)。
 
$html = curl_exec($curl);
//$html = mb_convert_encoding($html ,'utf-8' , 'gbk');
function characet($data){
  if( !empty($data) ){
    $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
    if( $fileType != 'UTF-8'){
      $data = mb_convert_encoding($data ,'utf-8' , $fileType);
    }
  }
  return $data;
}
$html=characet($html);


function return_preg_match($pattern, $content, $reg_key = 'content') {
        if (is_array($pattern)) {
            foreach ($pattern as $patt) {
                if (preg_match('/' . $patt . '/i', $content, $cont)) {
                    $cont = $cont[$reg_key];
                    break;
                } else {
                    $cont = false;
                } 
            } 
        } else {
            if (preg_match('/' . $pattern . '/i', $content, $cont)) {
                //$cont = $cont['match'];
            } else {
                $cont = false;
            } 
        } 
        return empty($cont)?'':$cont;
    } 
	
	
	$html=str_replace('&nbsp;','',$html);

       if (!empty($info['area_start']) || !empty($info['area_end'])) {
            $newConfig['reg_source_cont'] = $info['area_start'] . (!empty($info['area_end']) ? '(?P<match>[\s\S]+?)' : '(?P<match>[\s\S]+)') . $info['area_end'];
            $newConfig['reg_source_cont'] = str_replace ('(*)', '[\s\S]*?', $newConfig['reg_source_cont']);
            $newConfig['reg_source_cont'] = preg_replace ('/\\\*([\'\/])/', "\\\\$1", $newConfig['reg_source_cont']);
			
			        $zzb= $newConfig['reg_source_cont'];

					$zhengwen= return_preg_match($zzb,$html);
					if (isset($zhengwen['match'])){
					$zhengwen= $zhengwen['match'];
					}else{
						echo '规则可能不对';
					}
		
			preg_match_all('/[\x{4e00}-\x{9fff}<br>\:\,\。\……\“\”]+/u', $zhengwen, $matches_1);
			$str_1 = join('', $matches_1[0]);
			$str_1=str_replace('<首','',$str_1);

			echo $str_1;
			
        }else{
			
			preg_match_all('/[\x{4e00}-\x{9fff}<br>\:\,\。\……\“\”]+/u', $html, $matches_1);
			$str_1 = join('', $matches_1[0]);
			echo $str_1;
		}
		
		
	
 
?>

3、小说下载阅读器中目录页网址填本地网址就可以了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

玄星幻火

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值