V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Kakarrot
V2EX  ›  Visual Studio Code

想玩一玩 pytube,发现 vscode 终端好像没有走代理

  •  
  •   Kakarrot · 58 天前 · 1422 次点击
    这是一个创建于 58 天前的主题,其中的信息可能已经有所发展或是发生改变。

    clash 打开 Allow Lan\Tun Mode\System Proxy

    在 vscode 设置中设置http:Proxy:http://127.0.0.1:7890

    # !/usr/bin/python3
    # encoding=utf-8
    
    from pytube import YouTube
    from pytube.exceptions import VideoUnavailable
    
    video = YouTube("https://www.youtube.com/watch?v=tO_L8bik10k")
    
    print("Video_title = " + video.title)
    
    try:
        print(video.streams)
        print(video.title)
    except VideoUnavailable:
        print("视频不可用")
    except Exception as e:
        print(f"发生错误: {e}")
    
    

    为什么 title 可以打印出来,但是 streams 无法打印,并且返回发生错误: HTTP Error 400: Bad Request

    试了一下在 vscode 终端 ping youtube.com 连接超时

    第 1 条附言  ·  58 天前
    请教如何可以在 vscode 使用 pytube 的`streams()`方法?
    第 2 条附言  ·  58 天前
    好像是 pytube 的问题

    现在是不是没有可用的 python 第三方下载油管视频的包了?
    6 条回复    2024-07-22 17:15:56 +08:00
    xinhaih
        1
    xinhaih  
       58 天前
    能返回 title 和 http error 就说明已经走代理了,streams 无法打印应该有其他的问题。另外 ping 使用 icmp 协议不走 http 代理。
    ZekeRuan
        2
    ZekeRuan  
       58 天前
    我觉得是没有走代理,clash 无法代理系统层面,用软路由应该可以解决,而且谷歌系网站都不接受 icmp
    fgt1t5y
        3
    fgt1t5y  
       58 天前
    用 clash 的 tun 模式试试
    Vegetable
        4
    Vegetable  
       58 天前
    哥们儿们写代码甚至不愿意看一眼文档吗
    Kakarrot
        6
    Kakarrot  
    OP
       58 天前
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5462 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 01:33 · PVG 09:33 · LAX 18:33 · JFK 21:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.