mitchelljy / Trending-YouTube-Scraper

Python script that scrapes the currently trending YouTube videos in a variety of countries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get the json file as well

Noah-0214 opened this issue · comments

I ran the script and I got the csv files, but I wonder if I can get the json files as well?

Noah I ran the code for my country Italy, but I got only a dataset of 200 rows ? Do you know why? I was expecting a larger dataset

I think you are just getting data from that specific day, so I'm assuming there were just 200 trending videos that day

to get json...

def write_to_file(country_code, country_data):
print(f"Writing {country_code} data to file...")

if not os.path.exists(output_dir):
    os.makedirs(output_dir)

with open(f"{output_dir}/{time.strftime('%y.%d.%m')}_{country_code}_videos.json", "w+", encoding='utf-8') as file:
    json.dump(country_data, file, ensure_ascii=False, indent=2)