Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimitryzub/ae33c615906c4d3650e72c4682b87173 to your computer and use it in GitHub Desktop.
Save dimitryzub/ae33c615906c4d3650e72c4682b87173 to your computer and use it in GitHub Desktop.
youtube_serpapi_get_category_results
from serpapi import GoogleSearch
def get_category_results():
params = {
"api_key": "YOR_API_KEY",
"engine": "youtube",
"search_query": "mojang"
}
search = GoogleSearch(params)
results = search.get_dict()
for result in results['latest_from_minecraft']:
title = result['title']
link = result['link']
channel = result['channel']
published_date = result['published_date']
views = result['views']
extensions = result['extensions']
print(f'{title}\n{link}\n{channel}\n{published_date}\n{views}\n{extensions}\n')
get_category_results()
# part of the output:
'''
Ask Mojang #18: More Mobs!
https://www.youtube.com/watch?v=miKrxo3uaXU
{'name': 'Minecraft', 'link': 'https://www.youtube.com/user/TeamMojang', 'verified': True, 'thumbnail': 'https://yt3.ggpht.com/KYt9rfP_fcswzs2RzvossPvKHOcP7W2gWFylRpAskW7IadpfgUgUrhttiYGtLs-P-LufgXpuc9E=s68-c-k-c0x00ffffff-no-rj'}
2 days ago
574573
['New', 'CC']
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment