Aug-02-2020, 12:00 AM
(Aug-01-2020, 06:45 PM)pythonnewbie138 Wrote: I started looking into Selenium but I want the script to be OS-independent and Selenium only works on LinuxLook at web-scraping part-2 and search forum there is a lot info about this.
(Aug-01-2020, 06:45 PM)pythonnewbie138 Wrote: I'll probably use a YouTube API wrapper when I get back to this.Can use YouTube API directly with Requests.
This is the same as would enter a
python
in the search-box on youtube.com. import requests api_key = 'xxxyour-keyxxx' search = 'python' how_many_hit = 10 response = requests.get(f'https://www.googleapis.com/youtube/v3/search?part=snippet\ &maxResults={how_many_hit}&q={search}&type=video&key={api_key}') hits = response.json() print(hits['items'][0]['snippet']['title']) print(hits['items'][0]['snippet']['channelId'])
Output:Learn Python - Full Course for Beginners [Tutorial]
UC8butISFwT-Wl7EV0hUK0BQ