正在读取数据,页面载入中,请稍后...

新浪图床限制外链图片403不显示的解决方法【附懒人包】

新浪图床失效,新浪图床图片打开403不显示,新浪图床打开失效的解决方法,解决方法尽在小千个人博客网站。

一般的图片防盗链,加 <meta name="referrer" content="no-referrer"/> 标签,就能直接破防了。但是,这个新浪床图的图片,不支持外链,连内链都封,连自己都防,像这种狠起来连自己都打的,用referrer标签肯定是解决不了问题的。

之前,小千写了《自建的床图API接口代码,比市面上的既简单又稳定》一文,用的是奇虎的图片,但是,大家都觉得,还是新浪床图好用。下面,小千就把破防的方法教大家。

教程开始

①、新建 wpiimg.txt 文件,代码如下

0072Vf1pgy1foxk3yu6vwj31kw0w04k5
0072Vf1pgy1foxkfg4cj2j31hc0u01a9
0072Vf1pgy1foxkg53bgcj31kw0w01fi
0072Vf1pgy1foxkilshjxj31hc0u04hb
0072Vf1pgy1foxkg1zqesj31kw0w0tpf
0072Vf1pgy1foxkfrmrlgj31hc0u0wt1
0072Vf1pgy1foxkg877vyj31hc0u0ndz
0072Vf1pgy1fodqgm91nsj315o0xr4qq
0072Vf1pgy1foxlhdcvy8j31hc0u07iz
0072Vf1pgy1foxli80mamj31hc0u0kcw

这里都是新浪的图片哦。注:演示用的,图片不是很多,懒人包里面有上千图。

②、新建 index.php 文件,代码如下

<?php
error_reporting(0);
header('Content-type:text/html;charset=utf-8');
$str = explode("\n", file_get_contents('wpiimg.txt'));
$url = 'https://tva'.rand(1,4).'.sinaimg.cn/large/'.str_replace(array("\r","\n","\r\n"),'', $str[rand(0,count($str))]).'.jpg';
if (!empty($url) && substr($url,0,4)=='http') {
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_REFERER, 'https://www.baidu.com/');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	curl_setopt($ch, CURLOPT_HEADER,0);
	curl_setopt($ch, CURLOPT_POST, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
	curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
	$data = @curl_exec($ch);
	curl_close($ch);
	header("Content-type: image/jpeg");
	echo $data;
}
exit();
?>

③、直接输出图片,调用标签就是 index.php 文件名啦。如果你想外链输出,使用传入远程图片地址的方式,那就继续看下面的外链输出方法。

外链输出

①、新建 img.php 文件,代码如下

<?php
error_reporting(0);
header('Content-type:text/html;charset=utf-8');
$url = $_GET["url"];
if (!empty($url) && substr($url,0,4)=='http') {
	$dir = pathinfo($url);
	$host = $dir['dirname'];
	$ext = $dir['extension'];
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_REFERER, 'https://www.baidu.com/');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	curl_setopt($ch, CURLOPT_HEADER,0);
	curl_setopt($ch, CURLOPT_POST, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
	curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
	$data = @curl_exec($ch);
	curl_close($ch);
	$types = array(
		'gif'=>'image/gif',
		'jpeg'=>'image/jpeg',
		'jpg'=>'image/jpeg',
		'jpe'=>'image/jpeg',
		'png'=>'image/png',
	);
	$type = $types[$ext] ? $types[$ext] : 'image/jpeg';
	header("Content-type: ".$type);
	echo $data;
}
exit();
?>

新浪图床限制外链图片403不显示的解决方法【附懒人包】 - 全民博客

②、调用标签

http://你的网址.com/img.php?url=https://tva4.sinaimg.cn/large/0072Vf1pgy1foxlodt7kpj31kw0w0nii.jpg

完成啦,以上的两种方式,都能破防新浪图片。

懒人包下载

该部分是下载区

本地下载

破解图片防盗链,该文件放入任意支持PHP环境的网站下,即可访问使用,不依赖于任何框架。

本文结束

评论专区

发表评论

评论列表(无评论)