This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from serpapi import GoogleSearch | |
def get_category_results(): | |
params = { | |
"api_key": "YOR_API_KEY", | |
"engine": "youtube", | |
"search_query": "mojang" | |
} | |
search = GoogleSearch(params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
def get_category_results(): | |
options = Options() | |
# running selenium in headless mode | |
options.headless = True | |
driver = webdriver.Chrome(options=options) | |
driver.get('https://www.youtube.com/results?search_query=mojang') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
def get_movie_results(): | |
options = Options() | |
# running selenium in headless mode | |
options.headless = True | |
driver = webdriver.Chrome(options=options) | |
driver.get('https://www.youtube.com/results?search_query=mortal kombat 2021 movie') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
driver = webdriver.Chrome(executable_path='path/to/chromedriver.exe') | |
driver.get('https://duckduckgo.com/?q=rtx 3080&kl=us-en&ia=web') | |
for result in driver.find_elements_by_css_selector('.results--ads .result__body.links_main.links_deep'): | |
title = result.find_element_by_css_selector('.js-result-title-link').text | |
link = result.find_element_by_css_selector('.js-result-title-link').get_attribute('href') | |
source = result.find_element_by_css_selector('.js-result-extras-url').text | |
snippet = result.find_element_by_css_selector('.js-result-snippet > at').text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
import urllib.parse, re | |
driver = webdriver.Chrome(executable_path='path/tochromedriver.exe') | |
driver.get('https://duckduckgo.com/?q=elon musk&kl=us-en&ia=web') | |
for result in driver.find_elements_by_css_selector('#m1-0 .has-image'): | |
title = result.find_element_by_css_selector('#m1-0 .js-carousel-item-title').text.strip() | |
link = result.find_element_by_css_selector('#m1-0 .js-carousel-item-title').get_attribute('href') | |
source = result.find_element_by_css_selector('#m1-0 .result__url').text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
import re, urllib.parse | |
driver = webdriver.Chrome(executable_path='path/to/chromedriver.exe') | |
driver.get('https://duckduckgo.com/?q=elon musk dogecoin&kl=us-en&ia=web') | |
for result in driver.find_elements_by_css_selector('#m3-0 .has-image'): | |
title = result.find_element_by_css_selector('#m3-0 .js-carousel-item-title').text | |
link = result.find_element_by_css_selector('#m3-0 .module--carousel__body a').get_attribute('href') | |