Skip to content

Instantly share code, notes, and snippets.

View reefwing's full-sized avatar

David Such reefwing

View GitHub Profile
import requests
from bs4 import BeautifulSoup
import random
# Send GET request to Quotes to Scrape website
base_url = 'http://quotes.toscrape.com/page/{}/'
page_number = 1
quotes = []
while True:
import requests
from bs4 import BeautifulSoup
import random
# Send GET request to Quotes to Scrape website
url = 'http://quotes.toscrape.com/'
response = requests.get(url)
# Use BeautifulSoup to parse the HTML content of the response
soup = BeautifulSoup(response.content, 'html.parser')
import requests
from bs4 import BeautifulSoup
import random
# Initialize variables
base_url = "http://quotes.toscrape.com"
current_url = base_url
quotes = []
# Loop through all pages of quotes
import requests
from bs4 import BeautifulSoup
# Initialize variables
base_url = "http://quotes.toscrape.com"
current_url = base_url
quotes = []
# Loop through all pages of quotes
while True:
import requests
from bs4 import BeautifulSoup
# Send a request to the website and get its content
response = requests.get("http://quotes.toscrape.com")
content = response.content
# Parse the content with BeautifulSoup
soup = BeautifulSoup(content, "html.parser")
import requests
from bs4 import BeautifulSoup
# Send a request to the website and get its content
response = requests.get("http://quotes.toscrape.com")
content = response.content
# Parse the content with BeautifulSoup
soup = BeautifulSoup(content, "html.parser")
import pandas as pd
import requests
# Set the ticker value
ticker = "STW.AX"
# Define the URL to fetch data from Yahoo Finance
url = f'https://finance.yahoo.com/quote/{ticker}?p={ticker}'
# Define the header information for the request
# Define the header information for the request
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"}
# Send a GET request to the URL with the header information and retrieve the HTML content
response = requests.get(url, headers=headers)
import pandas as pd
import requests
# Set the ticker value
ticker = "STW.AX"
# Define the URL to fetch data from Yahoo Finance
url = f"https://finance.yahoo.com/quote/{ticker}/history?p={ticker}"
# Send a GET request to the URL and retrieve the HTML content
HEADERS = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}
# Make the request
response = requests.get(url, headers = HEADERS)