Skip to content

Instantly share code, notes, and snippets.

Avatar
🇺🇦
Grateful. Donating to Ukraine

Dmitiry Zub☀️ dimitryzub

🇺🇦
Grateful. Donating to Ukraine
View GitHub Profile
@dimitryzub
dimitryzub / scrape-google-finance-markets-page.py
Last active Aug 2, 2022
Script for scraping Google Finance Markets with Python
View scrape-google-finance-markets-page.py
# tutorial blog post: https://serpapi.com/blog/scrape-google-finance-markets-in-python/
import requests
import json
import re
import argparse
from parsel import Selector
parser = argparse.ArgumentParser(prog="Google Finance Markets Options")
parser.add_argument('-i','--indexes', action="store_true")
@dimitryzub
dimitryzub / scrape_google_finance_ticker_python.py
Last active Jul 28, 2022
A script that scrapes Google Finance Ticker in Python - google.com/finance/quote/
View scrape_google_finance_ticker_python.py
import nasdaqdatalink
import requests, json, re
from parsel import Selector
from itertools import zip_longest
def scrape_google_finance(ticker: str):
params = {
"hl": "en" # language
}
@dimitryzub
dimitryzub / scrape-google-finance-main-page.py
Created Jul 28, 2022
Script for scraping Google Finance main page in Python 🐍
View scrape-google-finance-main-page.py
# original blog post: https://serpapi.com/blog/web-scraping-google-finance/
import requests, json, re
from parsel import Selector
def scrape_google_finance_main_page():
# https://docs.python-requests.org/en/master/user/quickstart/#custom-headers
# https://www.whatismybrowser.com/detect/what-is-my-user-agent
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36"
@dimitryzub
dimitryzub / scrape-google-images-python.py
Last active Jul 25, 2022
Web scraping all Google Images in Python
View scrape-google-images-python.py
# Step-by-step blog post: https://serpapi.com/blog/scrape-google-images-with-python/
# There's an API solution with a video tutorial: https://www.youtube.com/watch?v=QuCPV6_GT6o
import os, requests, lxml, re, json, urllib.request
from bs4 import BeautifulSoup
from serpapi import GoogleSearch
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
}
@dimitryzub
dimitryzub / scrape-google-images-python-serpapi.py
Last active Jul 21, 2022
Scrape Google Images with Python and SerpApi web scraping library
View scrape-google-images-python-serpapi.py
def serpapi_get_google_images():
image_results = []
for query in ["Coffee", "boat", "skyrim", "minecraft"]:
# search query parameters
params = {
"engine": "google", # search engine. Google, Bing, Yahoo, Naver, Baidu...
"q": query, # search query
"tbm": "isch", # image results
@dimitryzub
dimitryzub / webscraping-all-goolgle-news-articles.py
Created Jul 13, 2022
How to Web Scrape all Google News Articles with Python and SerpApi
View webscraping-all-goolgle-news-articles.py
# video tutorial: https://www.youtube.com/watch?v=fOs_eOsLP54
from serpapi import GoogleSearch
from urllib.parse import (parse_qsl, urlsplit)
params = {
"api_key": "...", # serpapi api key
"engine": "google", # search engine
"q": "minecraft", # search query
"gl": "us", # country of the search
@dimitryzub
dimitryzub / serpapi-google-sports-results-timezone-format.py
Created Jul 5, 2022
#AskSerpApi: "When using sport results API, what timezone do you guys use? The time and date responses are changing."
View serpapi-google-sports-results-timezone-format.py
# AskSerpApi video: https://www.youtube.com/watch?v=c26LgucCqDo
from dateutil import parser
from serpapi import GoogleSearch
params = {
"api_key": "your serpapi api key",
"engine": "google",
"q": "liverpool",
"google_domain": "google.co.uk",
@dimitryzub
dimitryzub / scrape-youtube-videos-python-serpapi.py
Last active Jul 4, 2022
Web Scraping YouTube Popular Videos Results Data with Python and SerpApi
View scrape-youtube-videos-python-serpapi.py
# video tutorial: https://www.youtube.com/watch?v=PTLpbBiz_sc
from serpapi import GoogleSearch
from urllib.parse import (parse_qsl, urlsplit)
import json
params = {
"api_key": "your api key", # your serpapi api key
"engine": "youtube", # serpapi parsing engine
"search_query": "blender foundation", # search query
@dimitryzub
dimitryzub / scrape-google-maps-photos-python.py
Last active Jun 22, 2022
Web Scrape Google Maps Photos with Python and SerpApi
View scrape-google-maps-photos-python.py
# video: https://www.youtube.com/watch?v=XM9d8zTYp_U
from serpapi import GoogleSearch
from urllib.parse import urlsplit, parse_qsl
import json
params = {
"api_key": "serpapi api key", # your api key
"engine": "google_maps_photos", # serpapi search engine
"hl": "en", # language of the search
@dimitryzub
dimitryzub / scrape-google-maps-place-python.py
Created Jun 22, 2022
Web Scraping Google Maps Place in Python | SerpApi
View scrape-google-maps-place-python.py
# video: https://www.youtube.com/watch?v=jqoNHXiGeZA
from serpapi import GoogleSearch
import json
params = {
"api_key": "your-serpapi-api-key", # Your SerpApi Api key
"engine": "google_maps", # SerpApi Parsing Engine
"google_domain": "google.com", # Google domain
"ll": "@47.6062572,-122.4086176,12z", # GPS Coordinates