Kakarrot

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

  •  
  •   Kakarrot · Jul 22, 2024 · 2848 views
    This topic created in 707 days ago, the information mentioned may be changed or developed.

    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 连接超时

    Supplement 1  ·  Jul 22, 2024
    请教如何可以在 vscode 使用 pytube 的`streams()`方法?
    Supplement 2  ·  Jul 22, 2024
    好像是 pytube 的问题

    现在是不是没有可用的 python 第三方下载油管视频的包了?
    6 replies    2024-07-22 17:15:56 +08:00
    xinhaih
        1
    xinhaih  
       Jul 22, 2024
    能返回 title 和 http error 就说明已经走代理了,streams 无法打印应该有其他的问题。另外 ping 使用 icmp 协议不走 http 代理。
    ZekeRuan
        2
    ZekeRuan  
       Jul 22, 2024
    我觉得是没有走代理,clash 无法代理系统层面,用软路由应该可以解决,而且谷歌系网站都不接受 icmp
    fgt1t5y
        3
    fgt1t5y  
       Jul 22, 2024
    用 clash 的 tun 模式试试
    Vegetable
        4
    Vegetable  
       Jul 22, 2024
    哥们儿们写代码甚至不愿意看一眼文档吗
    Kakarrot
        6
    Kakarrot  
    OP
       Jul 22, 2024
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   995 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 19:05 · PVG 03:05 · LAX 12:05 · JFK 15:05
    ♥ Do have faith in what you're doing.