Skip to content

Instantly share code, notes, and snippets.

@dimitryzub
Created June 20, 2021 05:06
Show Gist options
  • Save dimitryzub/61b58efdb09ed081c9c3ea9fc8271b14 to your computer and use it in GitHub Desktop.
Save dimitryzub/61b58efdb09ed081c9c3ea9fc8271b14 to your computer and use it in GitHub Desktop.
serpapi_youtube_get_ads
from serpapi import GoogleSearch
def get_video_ad_results():
params = {
"api_key": "YOUR_API_KEY",
"engine": "youtube",
"search_query": "how to tie a tie"
}
search = GoogleSearch(params)
results = search.get_dict()
for result in results['ads_results']:
title = result['title']
link = result['link']
channel = result['channel']
description = result['description']
print(f'{title}\n{link}\n{channel}\n{description}\n')
get_video_ad_results()
# output:
'''
How to tie a tie EASY WAY
https://www.youtube.com/watch?v=X_3z7QneFOI
{'name': 'How to tie a tie', 'link': 'https://www.youtube.com/channel/UC4UuK5vs0b8HhqLDE6ssWOA'}
How to tie a tie quick and easy Best tutorial
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment