HFrost0 / bilix

⚡️Lightning-fast async download tool for bilibili and more
Apache License 2.0
1.61k stars 169 forks source link

本地运行 jable 用例时报错 403 #58

Closed linbuxiao closed 8 months ago

linbuxiao commented 1 year ago

看起来是 cloudflare wall,该如何解决这个问题?

PS:是否考虑引入 selenium ?

HFrost0 commented 1 year ago

刚试了一下好像没遇上403,可能你的代理被限制了?如果你的浏览器进去,可以暂时通过直接提供m3u8链接的方式进行下载

selenuim太笨重太慢了,不到万不得已不会用的

HFrost0 commented 1 year ago

我估计你可能问的是新的站点,PR中403出现的原因:

  1. 对于不支持http2协议的站点打开http2可能导致403
  2. 下载器没有import到init.py 导致实际上用的bilibili的downloader进行的请求
linbuxiao commented 1 year ago

刚试了一下好像没遇上403,可能你的代理被限制了?如果你的浏览器进去,可以暂时通过直接提供m3u8链接的方式进行下载

selenuim太笨重太慢了,不到万不得已不会用的

不是新 PR,是已有的 jable 用例。如果你没有遇到那应该是我个人 ip 的问题。先关闭 issue。

Adam-Jin commented 1 year ago

对于返回403的问题,可能是cloudflare校验了TLS指纹,httpx换成curl_cffi可以正常请求。

linbuxiao commented 1 year ago

对于返回403的问题,可能是cloudflare校验了TLS指纹,httpx换成curl_cffi可以正常请求。

这真的是一个神奇的库。

curl https://jable.tv/models/393ec3548aecc34004d54e03becd2ea9/
<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">

当我直接使用 curl 时,被 403 跳转,当然这可能是由于我代理的可用性问题。

于是我切换到了 curl-impersonate,也就是 @Adam-Jin 提到的依赖库。

docker run --rm lwthiker/curl-impersonate:0.5-chrome curl_chrome110 https://jable.tv/models/393ec3548aecc34004d54e03becd2ea9/
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<!doctype html>
<html lang="en">
<head>
<title>佐久良咲希出演的AV在線看 - Jable.TV | 免費高清AV在線看 | J片 AV看到飽</title>

正常获取到了结果!这真是太厉害了。

目前我还在看库的实现方式,毕竟我对于 tls 指纹相关的知识了解的很少。

@HFrost0 你觉得需要 reopen 这个 issue 吗?

HFrost0 commented 1 year ago

@linbuxiao 我也不了解这个,当时关闭这个问题的时候我还可以正常访问api,但是现在也403了,真的可以研究一下是怎么做的

linbuxiao commented 1 year ago

image

目前这个 python 库 的实现好像有些不稳定,在 README 中说到打包方式有问题。所以可能会破坏原有功能的稳定性(当然我们可以先通过选项方式支持)。好消息是支持了异步。

linbuxiao commented 1 year ago

jable 开启的 TLS 指纹检测 + http2 指纹检测目前没有更好地方式绕过,因为涉及到了 TLS 指纹加密套件修改,http2 连接模式,header 顺序修改。使用 curl-impersonate 是目前最好的方式。

目前通过编码形式绕过 cloudflare 墙的库有 golang 的 req,其中依赖了 utls。python 的实现方式大多为调用封装好的 curl 的 c 库来实现。

HFrost0 commented 1 year ago

对于这个站点一个其他的解决办法,可以使用1.0版本的autov和浏览器脚本或selenium配合下载

linbuxiao commented 1 year ago

对于这个站点一个其他的解决办法,可以使用1.0版本的autov和浏览器脚本或selenium配合下载

autov 是指?

HFrost0 commented 1 year ago

@linbuxiao https://github.com/HFrost0/bilix/blob/1.0/bilix/download/auto_downloader.py