Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xiaobailoves opened this issue Aug 30, 2021 · 11 comments
Open

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

xiaobailoves opened this issue Aug 30, 2021 · 11 comments

Comments

@xiaobailoves
Copy link

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

@journey-ad
Copy link
Owner

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

@xiaobailoves
Copy link
Author

xiaobailoves commented Aug 30, 2021

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

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

@journey-ad
Copy link
Owner

可以搜 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
Copy link
Author

可以搜 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
Copy link
Author

xiaobailoves commented Aug 30, 2021

可以搜 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
Copy link
Owner

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

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

@xiaobailoves
Copy link
Author

xiaobailoves commented Aug 31, 2021

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

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

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

@journey-ad
Copy link
Owner

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

@xiaobailoves
Copy link
Author

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

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

@journey-ad
Copy link
Owner

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

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

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

@xiaobailoves
Copy link
Author

xiaobailoves commented Oct 6, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants