web scrape forex live prices code example
Example 1: web scrape forex live prices
list_of_rows = []
links = []
#Filtering events that have a href link
for row in table.find_all('tr', {'data-eventid':True}):
list_of_cells = []
#Filtering high-impact events
for span in row.find_all('span', class_='high'):
links.append(url + "#detail=" + row['data-eventid'])
#Extracting the values from the table data in each table row
for cell in row.find_all('td', class_=[
'calendar__cell calendar__currency currency',
'calendar__cell calendar__event event',
'calendar__cell calendar__actual actual',
'calendar__cell calendar__forecast forecast',
'calendar__cell calendar__previous previous']):
list_of_cells.append(cell.text)
list_of_rows.append(list_of_cells)
Example 2: web scrape forex live prices
links.append(url + "#detail=" + row['data-eventid'])
Example 3: web scrape forex live prices
table = soup.find('table', class_='calendar__table')
Example 4: web scrape forex live prices
import pandas as pd
import time
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
url = 'https://www.forexfactory.com/calendar.php?month=last'
response = requests.get(url)
data = response.text
soup = BeautifulSoup(data, 'lxml')