Tuesday, 15 November 2016

The Hindu news finder with python BeautifulSoup

Web scrapping with python BeautifulSoup

Dig out web Data .

URL used: http://www.thehindu.com/news/

With this script  i am going to dig data of The hindu news service of india . It will bring you what are the recent news published in this news website .

 


I am  going to bring only those news which are latest , i have marked as round .

import os,requests
from bs4 import BeautifulSoup
r=requests.get('http://www.thehindu.com/news/')
file=BeautifulSoup(r.content)
os.system('clear')
print "Bellow are recent news with time and headlines."
print file.find_all("div",{"class":"headlines"})[0].text
print "\n\nBellow are the links for the above news , visit for more info:\n\n"
for i in file.find_all("div",{"class":"headlines"})[0].find_all('a'):
        print i.get('href')


Out of my script is as bellow :




Next i will scrap data  from another site . I will dig out  all the link and download Picture that is available in any website  .


Monday, 14 November 2016

Scrap out current stoke price of any company using Python and BeautifulSoup

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 .








Popular Posts