获得一定数量的订户后,会自动订阅YouTube频道
我的问题是,可以让一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用Selenium,在HTML中找到订阅按钮,然后单击它。 Selenium Code的示例(与Selenium Docs不同的网站):
获取更多信息: 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):
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.
请注意,您可以仅获得三个重要数字订户数量。
@game开发共享由于需要为此目的,需要将网络浏览器专用于此,这可能很重除了由YouTube解释为垃圾邮件流量。
我会建议您使用 channels:list list 使用
> part = statistics
在item [“ 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 initem["statistics"]["subscriberCount"]
and then Subscriptions: insert to subscribe to the given YouTube channel.