This file contains hidden or 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
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: |
This file contains hidden or 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
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') |
This file contains hidden or 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
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 |
This file contains hidden or 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
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: |
This file contains hidden or 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
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") |
This file contains hidden or 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
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") |
This file contains hidden or 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
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 |
This file contains hidden or 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
# 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) |
This file contains hidden or 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
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 |
This file contains hidden or 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
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) |