nodejs做盗链图片中转 nodejs做盗链图片中转

nodejs做盗链图片中转

var express = require('express');
var router = express.Router();
var request = require('request');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {

var url=req.query.url;
    var options = {
         method: "GET",
         url:url,
         headers:{
            "Referer": request.host
         }
     };
     request(options).pipe(res);
});

module.exports = router;



<?php  
    function Crack_img($url,$refer){  
    $ch = curl_init($url);  //设置图片url
    curl_setopt ($ch, CURLOPT_REFERER, $refer);  //伪造请求来源
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);  
    $data = curl_exec($ch);  
    curl_close($ch);  
      
    //$ext = strtolower(substr(strrchr($img,'.'),1,10));  
    //输出图片格式
    /*$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:image/jpeg");  //输出二进制流图片
    return $data;}
        $url = $_GET["url"];  
        $refer = $_GET['refer'];
        echo Crack_img($url,$refer);
https://image.baidu.com/search/down?tn=download&url=


分享本文至:

评论 0

挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论