This site is developed to XHTML and CSS2 W3C standards.
If you see this paragraph, your browser does not support those standards and you
need to upgrade. Visit WaSP
for a variety of options.
Paste #669
Posted by: BitByByte
Posted on: 2026-04-01 22:22:58
Age: 6 days ago
Views: 37
import requests
import time
API_KEY = "КЛЮЧ СЮДА"
URL = "https://www.googleapis.com/youtube/v3/search"
queries = [
"a", "b", "c", "the", "funny", "music", "video",
"lol", "game", "test", "tv", "news"
]
published_after = "2005-01-01T00:00:00Z"
published_before = "2006-01-01T00:00:00Z"
video_ids = set()
def search(query, page_token=None):
params = {
"part": "snippet",
"q": query,
"type": "video",
"publishedAfter": published_after,
"publishedBefore": published_before,
"maxResults": 50,
"order": "date",
"key": API_KEY
}
if page_token:
params["pageToken"] = page_token
r = requests.get(URL, params=params)
return r.json()
for q in queries:
print("Searching:", q)
next_page = None
for _ in range(10):
data = search(q, next_page)
for item in data.get("items", []):
vid = item["id"]["videoId"]
video_ids.add(vid)
next_page = data.get("nextPageToken")
if not next_page:
break
time.sleep(0.2)
print("Total videos:", len(video_ids))
# сохраняем ссылки
with open("videos_2005.txt", "w", encoding="utf-8") as f:
for vid in video_ids:
f.write(f"https://www.youtube.com/watch?v={vid}\n")
print("Saved to videos_2005.txt")
Download raw |
Create new paste