diff --git a/database/insert_row.py b/database/insert_row.py index 29aa3d8..0958c29 100644 --- a/database/insert_row.py +++ b/database/insert_row.py @@ -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','arun@bin.com');" cursor.execute(sql) db.close() diff --git a/database/mysql_connection.py b/database/mysql_connection.py index d2719e8..296f4c8 100644 --- a/database/mysql_connection.py +++ b/database/mysql_connection.py @@ -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() \ No newline at end of file diff --git a/database/select_command.py b/database/select_command.py index 1b3bcb9..c55956f 100644 --- a/database/select_command.py +++ b/database/select_command.py @@ -12,7 +12,7 @@ import MySQLdb # Open database connection db = MySQLdb.connect("localhost","root","ramji","cable" ) -cursor = db.cursor(); +cursor = db.cursor() sql ="select * from customer" cursor.execute(sql) results = cursor.fetchall() diff --git a/delete All File with extension_EXE.py b/delete All File with extension_EXE.py index f115bdf..e0180da 100644 --- a/delete All File with extension_EXE.py +++ b/delete All File with extension_EXE.py @@ -18,7 +18,7 @@ def main(): root.withdraw() directory = filedialog.askdirectory() #source folder count=0 - for root,files in os.walk(directory): + for root, SubFolders , files in os.walk(directory): os.chdir(root) files = glob.glob('*.exe') for filename in files: diff --git a/error.py b/error.py new file mode 100644 index 0000000..02c5f5b --- /dev/null +++ b/error.py @@ -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) \ No newline at end of file diff --git a/fileHandling/file_read.py b/fileHandling/file_read.py index b393bea..6ac8ac4 100644 --- a/fileHandling/file_read.py +++ b/fileHandling/file_read.py @@ -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() \ No newline at end of file diff --git a/gre.py b/gre.py new file mode 100644 index 0000000..a60ab86 --- /dev/null +++ b/gre.py @@ -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) \ No newline at end of file diff --git a/list_idea.py b/list_idea.py new file mode 100644 index 0000000..a0e59f9 --- /dev/null +++ b/list_idea.py @@ -0,0 +1,3 @@ +list = [1, 1, 2, 3, 5, 8, 13] +print(list[list[4]]) + diff --git a/list_idea1.py b/list_idea1.py new file mode 100644 index 0000000..e69de29 diff --git a/newsfeed.py b/newsfeed.py new file mode 100644 index 0000000..50384c6 --- /dev/null +++ b/newsfeed.py @@ -0,0 +1,42 @@ +""" +-*- coding: utf-8 -*- +======================== +Python Desktop News Notifier +======================== +Developed by: Chirag Rathod (Srce Cde) +Email: chiragr83@gmail.com +======================== +""" + +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") \ No newline at end of file diff --git a/turtlePrg.py b/turtlePrg.py new file mode 100644 index 0000000..cb00604 --- /dev/null +++ b/turtlePrg.py @@ -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() \ No newline at end of file diff --git a/webscraper/news_reader.py b/webscraper/news_reader.py new file mode 100644 index 0000000..64702b5 --- /dev/null +++ b/webscraper/news_reader.py @@ -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) \ No newline at end of file diff --git a/webscraper/nscPrice.py b/webscraper/nscPrice.py new file mode 100644 index 0000000..0260d5e --- /dev/null +++ b/webscraper/nscPrice.py @@ -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) diff --git a/webscraper/timeofindia.py b/webscraper/timeofindia.py new file mode 100644 index 0000000..a471d99 --- /dev/null +++ b/webscraper/timeofindia.py @@ -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) \ No newline at end of file diff --git a/webscraper/youtubeDownloader.py b/webscraper/youtubeDownloader.py index bafcaa5..b1ea1b8 100644 --- a/webscraper/youtubeDownloader.py +++ b/webscraper/youtubeDownloader.py @@ -4,4 +4,4 @@ import shutil ydl_opts = {} with youtube_dl.YoutubeDL(ydl_opts) as ydl: - ydl.download(['https://www.youtube.com/watch?v=v8g9arm8nFI&list=PL9rywNkH9WIPqi-YhUlq_pCYaqE0HyaQs']) \ No newline at end of file + ydl.download(['https://www.youtube.com/watch?v=e2D-kjOMNF0']) \ No newline at end of file diff --git a/zen.py b/zen.py new file mode 100644 index 0000000..9839e63 --- /dev/null +++ b/zen.py @@ -0,0 +1 @@ +import this \ No newline at end of file