From 06a3673a50f1bba9fdf5810d12613cd56fffc4fe Mon Sep 17 00:00:00 2001 From: Firoz Ahmed Date: Sun, 8 Dec 2024 18:37:43 +0530 Subject: [PATCH] Update app.py --- app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 812ed5d..f22d83d 100644 --- a/app.py +++ b/app.py @@ -2,6 +2,10 @@ import re import requests +headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36' # Example User-Agent string +} + def read_handles(file_path): with open(file_path, 'r') as f: return [tuple(line.strip().split(',')) for line in f] @@ -9,7 +13,7 @@ def read_handles(file_path): def fetch_channel_data(handle): url = f'https://www.youtube.com/@{handle}/live' try: - response = requests.get(url) + response = requests.get(url, timeout=10, headers=headers) response.raise_for_status() except requests.RequestException as e: print(f"Error fetching data for handle {handle}: {e}")