gpt4 book ai didi

web-scraping - 如何首先从特定 channel 抓取新的YouTube视频?

转载 作者:行者123 更新时间:2023-12-03 05:48:43 25 4
gpt4 key购买 nike

我有一个 channel ,我想从中尽快获取新上传的视频。最好的方法是什么?我知道两种选择:

  • 使用YouTube API
  • 直接通过URL访问 channel

  • 使用选项1时,我需要调用api才能获取视频列表。由于存在配额,我想我将用尽我可以进行的api调用。我认为选项2是最好的选择,因为我可以根据需要多次调用该url。

    首先可以通过api获得新视频吗?还是根据用户来自不同的地区,在不同时间向用户提供通过url访问的视频?我自己建立了一个网址抓取工具。我每分钟都会访问该网址。仍然有人在我有视频前8分钟播放视频。我不明白为什么会这样。

    最佳答案

    只是为了补充一点MadRay编写的内容,您可以使用此URL做一些简单的字符串替换

    使用 channel ID:

    "https://www.youtube.com/feeds/videos.xml?channel_id=UCXuqSBlHAE6Xw-yeJA0Tunw"

    使用 channel 名称:
    https://www.youtube.com/feeds/videos.xml?user=LinusTechTips

    拥有为您解析的自由。
    from bs4 import BeautifulSoup
    import requests

    url="https://www.youtube.com/feeds/videos.xml?user=LinusTechTips"
    html = requests.get(url)
    soup = BeautifulSoup(html.text, "lxml")

    for entry in soup.find_all("entry"):
    for title in entry.find_all("title"):
    print(title.text)
    for link in entry.find_all("link"):
    print(link["href"])
    for name in entry.find_all("name"):
    print(name.text)
    for pub in entry.find_all("published"):
    print(pub.text)

    响应:
    FINALLY Wireless Headphones that Sound GREAT
    https://www.youtube.com/watch?v=rei5vMQmD4Q
    Linus Tech Tips
    2020-01-30T20:04:37+00:00
    Don't give Apple your MONEY - Mac Pro Upgrade Adventure
    https://www.youtube.com/watch?v=zcLbSCinX3U
    Linus Tech Tips
    2020-01-29T19:59:56+00:00
    We got the Kick-Proof TV from China!
    https://www.youtube.com/watch?v=4eSADWuZskk
    Linus Tech Tips
    2020-01-28T19:46:09+00:00
    Everything went wrong... Water Cooled 8K Camera Final Test
    https://www.youtube.com/watch?v=OEUCNh5g-2I
    Linus Tech Tips
    2020-01-27T20:08:27+00:00
    I'm Returning my Mac Pro
    https://www.youtube.com/watch?v=mIB389tqzCI
    Linus Tech Tips
    2020-01-26T19:59:45+00:00
    The RGB HDMI cable ISN'T as dumb as you'd think...
    https://www.youtube.com/watch?v=nva6oPszm60
    Linus Tech Tips
    2020-01-25T20:06:23+00:00
    I am NOT Retiring... yet - WAN Show Jan 24, 2020
    https://www.youtube.com/watch?v=cxjhTVR_dJw
    Linus Tech Tips
    2020-01-25T02:29:50+00:00
    The Best VR Headset... got BETTER!?
    https://www.youtube.com/watch?v=AGScX_8plYw
    Linus Tech Tips
    2020-01-23T19:52:00+00:00
    I've been thinking of retiring.
    https://www.youtube.com/watch?v=hAsZCTL__lo
    Linus Tech Tips
    2020-01-23T06:35:25+00:00
    It’s time to upgrade your GPU - RX 5600 XT
    https://www.youtube.com/watch?v=rKn-vWDMkwQ
    Linus Tech Tips
    2020-01-22T19:59:36+00:00
    WE FINALLY DID IT!! - Water Cooling the 8K Camera!
    https://www.youtube.com/watch?v=imJ9QgOJHzY
    Linus Tech Tips
    2020-01-21T19:59:47+00:00
    We Water Cooled an SSD!!
    https://www.youtube.com/watch?v=lQmI5A27Iv8
    Linus Tech Tips
    2020-01-20T20:17:22+00:00
    Should you buy a $50 CPU??
    https://www.youtube.com/watch?v=JISJ_YTI9s0
    Linus Tech Tips
    2020-01-19T20:19:02+00:00
    Apple’s Pro Display XDR – A PC Guy’s Perspective
    https://www.youtube.com/watch?v=X089oYPc5Pg
    Linus Tech Tips
    2020-01-18T19:59:29+00:00
    The NSA is Giving Out It's Hacks for Free! - WAN Show Jan 17, 2020
    https://www.youtube.com/watch?v=af6FBA-n7eA
    Linus Tech Tips
    2020-01-18T03:00:04+00:00

    但是,请记住,请在请求中使用 header ,并注意避免一次过多地访问YouTube的后端,因为您的IP会暂时停用12小时。祝你好运!

    关于web-scraping - 如何首先从特定 channel 抓取新的YouTube视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59724101/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com