Web scrapping to find out current stoke price of any company with BeautifulSoup.
URL used : http://finance.yahoo.com
Dig out web data.
Part 2:
This tutorial is latest and it will work till atleast 6 month .
Say i want to know current stoke price of facebook,com , my this script will do it within seconds.

current stoke price of facebook is 115 . Lets see how my script find it .
import requests
import os
from bs4 import BeautifulSoup
r0=raw_input('Enter the company you wana know latest stok price:\n')
r=requests.get('https://finance.yahoo.com/quote/%s?p=%s'%(r0,r0))
file=BeautifulSoup(r.content)
g_data=file.find_all("span",{"class":"Fw(b) D(ib) Fz(36px) Mb(-4px)"})
os.system('clear')
print 'Current stok price of %s'%r0,'is: ',g_data[0].text


Now i will see the stock price of Tesla Motors .

Lets see how my script responses :

Nice its working fine . Next topic i will scrip data from an another site .
URL used : http://finance.yahoo.com
Dig out web data.
Part 2:
This tutorial is latest and it will work till atleast 6 month .
Say i want to know current stoke price of facebook,com , my this script will do it within seconds.
current stoke price of facebook is 115 . Lets see how my script find it .
import requests
import os
from bs4 import BeautifulSoup
r0=raw_input('Enter the company you wana know latest stok price:\n')
r=requests.get('https://finance.yahoo.com/quote/%s?p=%s'%(r0,r0))
file=BeautifulSoup(r.content)
g_data=file.find_all("span",{"class":"Fw(b) D(ib) Fz(36px) Mb(-4px)"})
os.system('clear')
print 'Current stok price of %s'%r0,'is: ',g_data[0].text
Now i will see the stock price of Tesla Motors .
Lets see how my script responses :
Nice its working fine . Next topic i will scrip data from an another site .
No comments:
Post a Comment