Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resolving YouTube search links
#11
(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 Linux
Look 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
Reply


Messages In This Thread
Resolving YouTube search links - by pythonnewbie138 - Jul-28-2020, 04:20 PM
RE: Resolving YouTube search links - by Larz60+ - Jul-28-2020, 04:28 PM
RE: Resolving YouTube search links - by Larz60+ - Aug-01-2020, 02:09 AM
RE: Resolving YouTube search links - by j.crater - Aug-01-2020, 08:08 AM
RE: Resolving YouTube search links - by j.crater - Aug-01-2020, 07:16 PM
RE: Resolving YouTube search links - by Axel_Erfurt - Aug-01-2020, 08:13 PM
RE: Resolving YouTube search links - by snippsat - Aug-02-2020, 12:00 AM
RE: Resolving YouTube search links - by snippsat - Aug-02-2020, 10:27 PM
RE: Resolving YouTube search links - by snippsat - Aug-04-2020, 04:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  webscrapping links and then enter those links to scrape data kirito85 2 3,242 Jun-13-2019, 02:23 AM
Last Post: kirito85

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020