Scraping Currency Data from Yahoo Finance with Python and Beautiful Soup

pip3 install beautifulsoup4
pip3 install requests soupsieve lxml
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'}
url='https://in.finance.yahoo.com/currencies'
response=requests.get(url,headers=headers)
print(response)
python3 yahoo_currency_bs.py
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'}
url='https://in.finance.yahoo.com/currencies'
response=requests.get(url,headers=headers)
soup=BeautifulSoup(response.content,'lxml')
for item in soup.select('[class*="data-row"]'):
try:
print(item)
print('------------------') except Exception as e:
raise e
print('')
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
url='https://in.finance.yahoo.com/currencies'header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
}
response=requests.get(url,headers=header)
soup=BeautifulSoup(response.content, 'lxml')for item in soup.select('[class*="data-row"]'):
print(item.select('.data-col0')[0].get_text())
print('____________________________')
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
url='https://in.finance.yahoo.com/currencies'header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
}
response=requests.get(url,headers=header)
soup=BeautifulSoup(response.content, 'lxml')for item in soup.select('[class*="data-row"]'):
print(item.select('.data-col0')[0].get_text())
print(item.select('.data-col1')[0].get_text())
print(item.select('.data-col2')[0].get_text())
print(item.select('.data-col3')[0].get_text())
print(item.select('.data-col4')[0].get_text())
print('____________________________')
curl "http://api.proxiesapi.com/?key=API_KEY&url=https://example.com"

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store