-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a04de22
commit 1b0d6cb
Showing
16 changed files
with
198 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,8 @@ | |
# Licence: MIT | ||
#------------------------------------------------------------------------------- | ||
import MySQLdb | ||
|
||
db = MySQLdb.connect("localhost","root","ramji","cable") | ||
cursor = db.cursor(); | ||
cursor = db.cursor() | ||
sql ="insert into customer values(20,'rakesh','jagdish','cf-4 arun vihar','12121212','[email protected]');" | ||
cursor.execute(sql) | ||
db.close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
|
||
#------------------------------------------------------------------------------- | ||
import MySQLdb | ||
|
||
|
||
# Open database connection | ||
db = MySQLdb.connect("localhost","root","ramji","cable" ) | ||
|
||
# prepare a cursor object using cursor() method | ||
cursor = db.cursor() | ||
|
||
# execute SQL query using execute() method. | ||
cursor.execute("SELECT VERSION()") | ||
|
||
# Fetch a single row using fetchone() method. | ||
data = cursor.fetchone() | ||
print("Database version : %s " % data ) | ||
|
||
# disconnect from server | ||
db.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sum = 0 | ||
for i in range(10): | ||
try: | ||
if 10 / i == 2: | ||
break | ||
except ZeroDivisionError: | ||
sum = sum+1 | ||
else: | ||
sum = sum +2 | ||
print("Sum :",sum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
file = open(r"C:\Users\acer\Desktop\pythonPrograms\fileHandling\abcd.txt",'r') | ||
file = open(r"C:\Users\acer\Desktop\PythonBox\pythonPrograms\fileHandling\abcd.txt",'r') | ||
data1 = file.read() | ||
print(data1) | ||
file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from bs4 import BeautifulSoup | ||
from random import randint | ||
import urllib | ||
import pynotify | ||
import time | ||
|
||
|
||
def sendMessage(title, message): | ||
pynotify.init("Test") | ||
notice = pynotify.Notification(title, message) | ||
notice.show() | ||
return | ||
|
||
webpage = urllib.urlopen('https://quizlet.com/58647605/kaplan-900-flash-cards').read() | ||
|
||
# Parse the entire webpage | ||
soup = BeautifulSoup(webpage) | ||
|
||
word = [] | ||
meaning = [] | ||
|
||
# Scrape words from soup | ||
for words in soup.find_all("span", class_="TermText qWord lang-en"): | ||
# Convert ascii to string | ||
word.append(words.text.encode("utf-8")) | ||
|
||
# Scrape meanings from soup | ||
for meanings in soup.find_all("span", class_="TermText qDef lang-en"): | ||
meaning.append(meanings.text.encode("utf-8")) | ||
|
||
print("Churning words !") | ||
|
||
|
||
while(1): | ||
index = randint(0,700) | ||
print(index) | ||
# First just pop the word on screen to wait for response | ||
sendMessage(word[index],"") | ||
# Adjust the response time between word and its meaning | ||
time.sleep(15) | ||
# Display the meaning with the word | ||
sendMessage(word[index], meaning[index]) | ||
# Time after which a new word pops on screen | ||
time.sleep(600) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
list = [1, 1, 2, 3, 5, 8, 13] | ||
print(list[list[4]]) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
-*- coding: utf-8 -*- | ||
======================== | ||
Python Desktop News Notifier | ||
======================== | ||
Developed by: Chirag Rathod (Srce Cde) | ||
Email: [email protected] | ||
======================== | ||
""" | ||
|
||
import feedparser | ||
import notify2 | ||
import time | ||
import os | ||
|
||
|
||
def Parsefeed(): | ||
f = feedparser.parse("http://feeds.bbci.co.uk/news/rss.xml") | ||
ICON_PATH = os.getcwd() + "/icon.ico" | ||
notify2.init('News Notify') | ||
|
||
for newsitem in f['items']: | ||
print(newsitem['title']) | ||
print(newsitem['summary']) | ||
print('\n') | ||
|
||
n = notify2.Notification(newsitem['title'], | ||
newsitem['summary'], | ||
icon=ICON_PATH | ||
) | ||
|
||
n.set_urgency(notify2.URGENCY_NORMAL) | ||
n.show() | ||
n.set_timeout(15000) | ||
time.sleep(1200) | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
Parsefeed() | ||
except: | ||
print("Error") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from turtle import * | ||
color('red', 'yellow') | ||
begin_fill() | ||
while True: | ||
forward(200) | ||
left(170) | ||
if abs(pos()) < 1: | ||
break | ||
end_fill() | ||
done() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
#importing necessary modules. | ||
import bs4 as bs | ||
import urllib.request | ||
from gtts import gTTS | ||
import vlc | ||
import time | ||
from mutagen.mp3 import MP3 | ||
|
||
#defining function to play sound. | ||
def reader(s): | ||
tts = gTTS(text=s, lang='en') | ||
tts.save("greeting.mp3") #saving as mp3 file | ||
p = vlc.MediaPlayer("greeting.mp3") #loading to media player | ||
f = MP3("greeting.mp3") | ||
n = f.info.length #getting duration of sound file | ||
p.play() #Playing sound | ||
time.sleep(n) #Sleeping for sub subprocess to take place | ||
|
||
#connecting to news site | ||
sauce = urllib.request.urlopen('https://news.google.co.in/').read() | ||
soup = bs.BeautifulSoup(sauce,'lxml') | ||
b=soup.body | ||
y='' | ||
m='' | ||
|
||
m="hello boss, you should check out following news \n" | ||
reader(m) | ||
|
||
#Webscraping text news with class esc-lead-title-wrapper | ||
for x in b.find_all("div", class_="esc-lead-article-title-wrapper"): | ||
y="\n"+x.text+"\n" | ||
reader(y) | ||
|
||
m=" \nThank you. that's all for the news today \n " | ||
reader(m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import requests | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from bs4 import BeautifulSoup | ||
import subprocess | ||
import requests | ||
import time | ||
|
||
url = "https://timesofindia.indiatimes.com/" | ||
|
||
def open_url(url): | ||
return requests.get(url).text # returns html | ||
|
||
def get_bsoup_object(html): | ||
return BeautifulSoup(html, "lxml") # returns soup (BeautifulSoup's object) | ||
|
||
|
||
def sendmessage(message): | ||
subprocess.Popen(['notepad.exe', message]) | ||
return | ||
|
||
|
||
def main(): | ||
myhtml = open_url(url) | ||
soup = get_bsoup_object(myhtml) | ||
j = 1 | ||
|
||
for i in soup.find('ul',attrs={'class':'list9'}).findAll('li'): | ||
#print(str(j) + " " + i.text) | ||
sendmessage(str(j) + " " + i.text) | ||
time.sleep(10) | ||
j += 1 | ||
|
||
|
||
|
||
while True: | ||
main() | ||
time.sleep(36000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import this |