web scraping youtube data i used this but its showing error could anyone correct me
kavitanegi369 opened this issue · 3 comments
kavitanegi369 commented
if name == "main":
import argparse
parser = argparse.ArgumentParser(description="YouTube Video Data Extractor")
parser.add_argument("url", help="URL of the YouTube video")
args = parser.parse_args()
# parse the video URL from command line
url = args.url
data = get_video_info(url)
# print in nice format
print(f"Title: {data['title']}")
print(f"Views: {data['views']}")
print(f"Published at: {data['date_published']}")
print(f"Video Duration: {data['duration']}")
print(f"Video tags: {data['tags']}")
print(f"Likes: {data['likes']}")
print(f"Dislikes: {data['dislikes']}")
print(f"\nDescription: {data['description']}\n")
print(f"\nChannel Name: {data['channel']['name']}")
print(f"Channel URL: {data['channel']['url']}")
print(f"Channel Subscribers: {data['channel']['subscribers'
usage: ipykernel_launcher.py [-h] url
ipykernel_launcher.py: error: unrecognized arguments: -f
x4nth055 commented
Hey there,
This script requires you enter the YouTube video URL in the command line, like so:
python youtube_data_extractor.py https://www.youtube.com/watch?v=jNQXAC9IVRwPlease confirm if this fixes your issue.
Thanks.
kavitanegi369 commented
i'm using jupyter notebook
x4nth055 commented
Then you shouldn't use argparse, specify your target video URL into url variable in the code, and comment out all argparse code.