获得一定数量的订户后,会自动订阅YouTube频道

发布于 2025-02-13 04:20:03 字数 838 浏览 0 评论 0原文

我的问题是,可以让一个python bot检查某个YouTube频道的订阅者,并且在该频道获得所需数量的订户以订阅我们之后?

例如,我正在查看拥有1490个订户的频道X,我想正是第1500订户。因此,代码需要每隔几分钟或秒刷新数字。

我该怎么做?

我有一个基本的python订户计数代码,但我坚持向前发展。

如果您有任何可以自动执行此操作的语言的代码,我将永远感谢您

当前的代码

from googleapiclient.discovery import build

# Create YouTube Object
youtube = build('youtube', 'v3',
                developerKey='Enter API key')

ch_request = youtube.channels().list(
    part='statistics',
    id='Enter Channel ID')

# Channel Information
ch_response = ch_request.execute()

sub = ch_response['items'][0]['statistics']['subscriberCount']
vid = ch_response['items'][0]['statistics']['videoCount']
views = ch_response['items'][0]['statistics']['viewCount']

print("Total Subscriber:- ", sub)
print("Total Number of Videos:- ", vid)
print("Total Views:- ", views)

my question is is it possible to have a Python bot checking every second the subscribers a certain YouTube channel has and after the channel gets a desired amount of subscribers to subscribe us to it?

For example I am looking at channel X that has 1490 subscribers and I want to be exactly the 1500th subscriber. So the code needs to refresh the number every few minutes or seconds.

How do I do that?

I have a basic Python subscriber count code but I am stuck at moving things forward.

If you have any code in any language that can do this automatically I will be forever grateful to you

My current code

from googleapiclient.discovery import build

# Create YouTube Object
youtube = build('youtube', 'v3',
                developerKey='Enter API key')

ch_request = youtube.channels().list(
    part='statistics',
    id='Enter Channel ID')

# Channel Information
ch_response = ch_request.execute()

sub = ch_response['items'][0]['statistics']['subscriberCount']
vid = ch_response['items'][0]['statistics']['videoCount']
views = ch_response['items'][0]['statistics']['viewCount']

print("Total Subscriber:- ", sub)
print("Total Number of Videos:- ", vid)
print("Total Views:- ", views)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2025-02-20 04:20:03

使用Selenium,在HTML中找到订阅按钮,然后单击它。 Selenium Code的示例(与Selenium Docs不同的网站):

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element(By.NAME, "q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

获取更多信息: https:// https:// Selenium-python.readthedocs.io/

至于连续运行它,只需使用一个循环并在所需的子计数为到达。

Use selenium, find the subscribe button in html and then click it. Example of selenium code (for a different website, from the selenium docs):

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element(By.NAME, "q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

Get more info at: https://selenium-python.readthedocs.io/

As for running it continuously, just use a loop and break out when the desired sub count is reached.

淡淡離愁欲言轉身 2025-02-20 04:20:03

请注意,您可以仅获得三个重要数字订户数量。

@game开发共享由于需要为此目的,需要将网络浏览器专用于此,这可能很重除了由YouTube解释为垃圾邮件流量。

我会建议您使用 channels:list list 使用> part = statisticsitem [“ statistics”] [“ subscribercount”]中获取订户计数,然后 subpcriptions:insert 订阅给定的YouTube通道。

Note that you can only get the three significant figures of the subscriber count.

@Game Developement shared a solution that may be quite heavy due to the need of having a web-browser dedicated for this purpose, in addition to be interpreted by YouTube as spam traffic.

I would instead recommend you to use Channels: list using part=statistics to get the subscriber count in item["statistics"]["subscriberCount"] and then Subscriptions: insert to subscribe to the given YouTube channel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文