journey-ad / pixiv-viewer

又一个Pixiv阅览工具
https://lab.getloli.com/pixiv-viewer/
MIT License
268 stars 57 forks source link

用github的peges功能构建后发现图片无法显示 #43

Open xiaobailoves opened 3 years ago

xiaobailoves commented 3 years ago

https://pixiv.yourworld.fun/#/home 请问图片是开了反盗链吗..... 希望开发者能回应我!感谢!

journey-ad commented 3 years ago

是的,演示使用的图片代理地址有防盗链,可以自行搭建代理服务

xiaobailoves commented 3 years ago

是的,演示使用的图片代理地址有防盗链,可以自行搭建代理服务

项目的地址能否发给我,谢谢大佬! 我是小白请见谅!抱歉!

journey-ad commented 3 years ago

可以搜 cloudflare workers pixiv 关键词,网上有很多文章 参考代码

const ALLOWEDREFERERS = [
  "lab.getloli.com",
  "localhost:3000",
  "localhost:8080",
  "www.pixiv.net",
]

addEventListener("fetch", event => {
  event.respondWith(imgProxy(event));
});

async function imgProxy(event) {
  //Begin
  let referer = event.request.headers.get("referer");
  if (referer) {
    let verified = false;
    for (let i = 0; i < ALLOWEDREFERERS.length; i++) {
      if (referer.includes(ALLOWEDREFERERS[i])) {
        verified = true;
        break;
      }
    }
    if (!verified) {
      return new Response('403 Forbidden', { status: 403, statusText: 'Forbidden' })
    }
  }
  //End

  let url = new URL(event.request.url);
  url.hostname = "i.pximg.net";

  let request = new Request(url, event.request);
  return fetch(request, {
    headers: {
      'Referer': 'https://www.pixiv.net/'
    }
  })
}
xiaobailoves commented 3 years ago

可以搜 cloudflare workers pixiv 关键词,网上有很多文章 参考代码

const ALLOWEDREFERERS = [
  "lab.getloli.com",
  "localhost:3000",
  "localhost:8080",
  "www.pixiv.net",
]

addEventListener("fetch", event => {
  event.respondWith(imgProxy(event));
});

async function imgProxy(event) {
  //Begin
  let referer = event.request.headers.get("referer");
  if (referer) {
    let verified = false;
    for (let i = 0; i < ALLOWEDREFERERS.length; i++) {
      if (referer.includes(ALLOWEDREFERERS[i])) {
        verified = true;
        break;
      }
    }
    if (!verified) {
      return new Response('403 Forbidden', { status: 403, statusText: 'Forbidden' })
    }
  }
  //End

  let url = new URL(event.request.url);
  url.hostname = "i.pximg.net";

  let request = new Request(url, event.request);
  return fetch(request, {
    headers: {
      'Referer': 'https://www.pixiv.net/'
    }
  })
}

感谢大佬!

xiaobailoves commented 3 years ago

可以搜 cloudflare workers pixiv 关键词,网上有很多文章 参考代码

const ALLOWEDREFERERS = [
  "lab.getloli.com",
  "localhost:3000",
  "localhost:8080",
  "www.pixiv.net",
]

addEventListener("fetch", event => {
  event.respondWith(imgProxy(event));
});

async function imgProxy(event) {
  //Begin
  let referer = event.request.headers.get("referer");
  if (referer) {
    let verified = false;
    for (let i = 0; i < ALLOWEDREFERERS.length; i++) {
      if (referer.includes(ALLOWEDREFERERS[i])) {
        verified = true;
        break;
      }
    }
    if (!verified) {
      return new Response('403 Forbidden', { status: 403, statusText: 'Forbidden' })
    }
  }
  //End

  let url = new URL(event.request.url);
  url.hostname = "i.pximg.net";

  let request = new Request(url, event.request);
  return fetch(request, {
    headers: {
      'Referer': 'https://www.pixiv.net/'
    }
  })
}

对了反代理搭好后还需要修改哪里才能让图片显示出来呢?大佬!

journey-ad commented 3 years ago

对了反代理搭好后还需要修改哪里才能让图片显示出来呢?大佬!

https://github.com/journey-ad/pixiv-viewer/blob/master/src/api/index.js#L19

xiaobailoves commented 3 years ago

对了反代理搭好后还需要修改哪里才能让图片显示出来呢?大佬!

https://github.com/journey-ad/pixiv-viewer/blob/master/src/api/index.js#L19

image 大佬这个接口国内无法访问.所以日榜还有搜索功能国内都无法使用?这个‘Ct = ’里面的接口 ' [似乎也导致了手机无法访问! 有办法能修复一下吗![我尝试搭了个反代理你的接口似乎还是没办法解决....

journey-ad commented 3 years ago

api 访问可能有些不稳定,现在已经恢复了,用的这个项目,可以自己搭一个

xiaobailoves commented 3 years ago
                        s.open("POST", "https://api.imjad.cn/pixivsearch/", !0),
                        s.send(r)
                    }), t.type || "image/png")
                },

图搜图的API有项目地址吗!大佬!

journey-ad commented 3 years ago
                      s.open("POST", "https://api.imjad.cn/pixivsearch/", !0),
                      s.send(r)
                  }), t.type || "image/png")
              },

图搜图的API有项目地址吗!大佬!

这个是对 saucenao.com 的封装,自己实现一下吧

xiaobailoves commented 3 years ago

大佬那个 https://hibiapi.getloli.com/ 又奔溃了