Skip to content

Commit

Permalink
winToaster and Nsc Price Ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed May 10, 2018
1 parent ccffb19 commit 55661f8
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 9 deletions.
28 changes: 28 additions & 0 deletions Text_Speech.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Import the required module for text
# to speech conversion
from gtts import gTTS
from playsound import playsound

# This module is imported so that we can
# play the converted audio
import os

# The text that you want to convert to audio
mytext = 'Welcome to binarynote.com and this is really amazing my dear!'

# Language in which you want to convert
language = 'en'

# Passing the text and language to the engine,
# here we have marked slow=False. Which tells
# the module that the converted audio should
# have a high speed
myobj = gTTS(text=mytext, lang=language, slow=False)

# Saving the converted audio in a mp3 file named
# welcome
myobj.save("welcome.mp3")

# Playing the converted file
#os.system("mpg321 welcome.mp3")
playsound("welcome.mp3")
Binary file modified dob.xls
Binary file not shown.
20 changes: 20 additions & 0 deletions mergesort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
x = [10,20,30,40,50]
y = [14,20,25,30]
z = []
i=j=k=0
while(i<5 and j<4):
if(x[i]<y[j]):
z.append(x[i])
i = i+1
else:
z.append(y[j])
j = j+1
while(i<4):
z.append(x[i])
i = i+1
while(j<5):
z.append(y[j])
j = j+1
print(z)


32 changes: 32 additions & 0 deletions notifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import time
import notify2
from topNews import topStories

# path to notification window icon
ICON_PATH = "put full path to icon image here"

# fetch news items
newsitems = topStories()

# initialise the d-bus connection
notify2.init("News Notifier")

# create Notification object
n = notify2.Notification(None, icon = ICON_PATH)

# set urgency level
n.set_urgency(notify2.URGENCY_NORMAL)

# set timeout for a notification
n.set_timeout(10000)

for newsitem in newsitems:

# update notification data for Notification object
n.update(newsitem['title'], newsitem['description'])

# show notification on screen
n.show()

# short delay between notifications
time.sleep(15)
2 changes: 1 addition & 1 deletion result.csv
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
5872966 ASHISH CHAUDHARY M 301 042 D2 027 078 A2 028 054 C1 048 054 D2 074 039 D2 B1 B1 B1 PASS
5872967 AMIT SINGH M 301 061 C2 027 092 A1 028 065 B1 048 076 B1 074 056 C2 A1 A2 A2 PASS
5872968 SAMEEKSHA NAGI F 301 091 A1 028 062 B1 037 083 B2 048 078 B1 074 064 C2 A1 A2 A2 PASS
5872969 BHAWNA Z F 301 061 C2 302 052 D1 037 061 D1 048 079 B1 074 064 C2 A1 A2 B1 PASS
5872969 BHAWNA Z F 301 061 C2 302 052 D1 037 061 D1 048 079 B1 074 064 C2 A1 A2 B1 PASS
5872970 SHUBH KHANNA M 301 062 C2 302 068 C1 037 079 C1 048 087 A2 074 059 C2 A2 B1 B1 PASS
5872971 VAISHNAVI SARASWAT F 301 065 C1 027 080 A2 028 055 B2 037 089 B1 048 067 C1 A1 A2 A2 PASS
5872972 VAISHNAVI SHANKAR F 301 080 B1 027 087 A1 028 080 A2 037 067 C2 048 081 B1 A1 A1 A1 PASS
Expand Down
Binary file modified result.xls
Binary file not shown.
3 changes: 3 additions & 0 deletions splitFunction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rakesh ="This is my first attempt my in python"
new1 = rakesh.split('my')
print(new1)
2 changes: 2 additions & 0 deletions test1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from subprocess import call
call(["notify-send", "This is title!", "This is message body!"])
53 changes: 53 additions & 0 deletions topNews.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import requests
import xml.etree.ElementTree as ET

# url of news rss feed
RSS_FEED_URL = "http://www.hindustantimes.com/rss/topnews/rssfeed.xml"

def loadRSS():
'''
utility function to load RSS feed
'''
# create HTTP request response object
resp = requests.get(RSS_FEED_URL)

# return response content
return resp.content

def parseXML(rss):
'''
utility function to parse XML format rss feed
'''
# create element tree root object
root = ET.fromstring(rss)

# create empty list for news items
newsitems = []

# iterate news items
for item in root.findall('./channel/item'):
news = {}

# iterate child elements of item
for child in item:

# special checking for namespace object content:media
if child.tag == '{http://search.yahoo.com/mrss/}content':
news['media'] = child.attrib['url']
else:
news[child.tag] = child.text.encode('utf8')
newsitems.append(news)

# return news items list
return newsitems

def topStories():
'''
main function to generate and return news items
'''
# load rss feed
rss = loadRSS()

# parse XML
newsitems = parseXML(rss)
return newsitems
36 changes: 28 additions & 8 deletions webscraper/nscPrice.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import requests
import time
from win10toast import ToastNotifier
import webbrowser
from bs4 import BeautifulSoup

url ="http://www.moneycontrol.com/india/stockpricequote/banks-private-sector/idfcbank/IDF01"
site = requests.get(url)
#print(site.text)
soup = BeautifulSoup(site.text,"html.parser")
for link in soup.select('#Nsc_Prc_tick_div'):
print(link)
name = link.get('strong')
print(name)
def current_price(url):
site = requests.get(url)
# toaster = ToastNotifier()
# toaster.show_toast("Hello World!!!", "Python is awesome and I am learning a lot!",icon_path=None, duration=160)
#print(site.text)
# while toaster.notification_active(): time.sleep(0.1)
soup = BeautifulSoup(site.text,"html.parser")
for link in soup.find_all("span", id ="Nse_Prc_tick"):
# #print(link)
name = link.getText()
#print('current Price :',name)
#toaster.show_toast("IDFC Bank!!!", "Current Price :"+str(name),icon_path=None, duration=30)
return name

while True:
toaster = ToastNotifier()
idfc = current_price("http://www.moneycontrol.com/india/stockpricequote/banks-private-sector/idfcbank/IDF01")
hind = current_price("http://www.moneycontrol.com/india/stockpricequote/metals-non-ferrous/hindustancopper/HC07")
ab = current_price("http://www.moneycontrol.com/india/stockpricequote/finance-investments/adityabirlacapital/ABC9")
cadila = current_price("http://www.moneycontrol.com/india/stockpricequote/pharmaceuticals/cadilahealthcare/CHC")
mep = current_price("http://www.moneycontrol.com/india/stockpricequote/infrastructure-general/mepinfrastructuredevelopers/MID")

rates ="IDFC Bank : " + str(idfc) + "\tHind Copper : " +str(hind) +"\nAB Capital : "+str(ab)
rates = rates +"\nCadila Heathcare : "+str(cadila) +"\nMEP infra :"+ str(mep)
toaster.show_toast("Price Alert!!!", rates,icon_path=None, duration=30)
time.sleep(60)
Binary file added welcome.mp3
Binary file not shown.

0 comments on commit 55661f8

Please sign in to comment.