Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import urllib.request
- from bs4 import BeautifulSoup
- from datetime import datetime, timedelta
- import re
- def supacha_scanner(url):
- response = requests.get(url)
- soup = BeautifulSoup(response.text, "html.parser")
- supacha_elements = soup.find_all('a', href=re.compile("superchat"))
- supacha_sum = 0
- for element in supacha_elements:
- supacha = element.text.replace(',', '')
- supacha = supacha[:-3]
- supacha_sum += int(supacha)
- print(supacha_sum)
- return supacha_sum
- if __name__ == '__main__':
- start_date = datetime.strptime(input("start date(YYYY-MM-DD)(leave blank for today's total):"), "%Y-%m-%d")
- end_date = datetime.strptime(input("end date(YYYY-MM-DD)(leave blank for today's total):"), "%Y-%m-%d")
- total_supacha = 0
- if start_date == "" and end_date == "":
- total_supacha = supacha_scanner("https://www.hololyzer.net/youtube/realtime/index.html")
- delta = timedelta(days=1)
- while start_date <= end_date:
- print(start_date.strftime("%Y-%m-%d")+":")
- total_supacha += supacha_scanner("https://www.hololyzer.net/youtube/realtime/list/"+start_date.strftime("%Y-%m-%d")+".html")
- start_date += delta
- print(str(total_supacha)+"円")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement