diff --git a/fileHandling/Create_binary_file.py b/fileHandling/Create_binary_file.py new file mode 100644 index 0000000..a9264b4 --- /dev/null +++ b/fileHandling/Create_binary_file.py @@ -0,0 +1,18 @@ +# program to create a binary file of records - Just like structure +# made by : rakesh kumar +# Compiled on : 8-July-2018 + +import pickle +list =[] +while True: + roll = input("Enter student Roll No:") + sname = input("Enter student Name :") + student = {"roll":roll,"name":sname} + list.append(student) + choice= input("Want to add more record(y/n) :") + if(choice=='n'): + break + +file = open("student.dat","wb") +pickle.dump(list,file) +file.close() \ No newline at end of file diff --git a/fileHandling/delete All File with extension_EXE.py b/fileHandling/delete All File with extension_EXE.py index e0180da..8ac8bb5 100644 --- a/fileHandling/delete All File with extension_EXE.py +++ b/fileHandling/delete All File with extension_EXE.py @@ -21,6 +21,7 @@ def main(): for root, SubFolders , files in os.walk(directory): os.chdir(root) files = glob.glob('*.exe') + print(files) for filename in files: os.unlink(filename) count+=1 diff --git a/fileHandling/downloadPDF.py b/fileHandling/downloadPDF.py new file mode 100644 index 0000000..cd932ae --- /dev/null +++ b/fileHandling/downloadPDF.py @@ -0,0 +1,23 @@ +# program to download pdf file from any website. +#made by : rakesh kumar + +import urllib.request + +def download(tutorialName): + url = 'https://www.tutorialspoint.com/' + tutorialName + '/' + tutorialName + '_tutorial.pdf' + #url ="https://cbsetoday.com/wp-content/uploads/2018/05/MYSQL-ASS-4-class-XI.pdf" + downloadLocation = '' + + pdf = urllib.request.urlopen(url) + saveFile = open(downloadLocation + tutorialName + '.pdf', 'wb') # because pdf is a binary file + saveFile.write(pdf.read()) + saveFile.close() + print('Downloaded!') + +if __name__ == '__main__': + while True: + tutorialName = input('Name of the tutorial pdf to be downloaded: ') + download(tutorialName) + choice = input("Do you want to download more PDF(y/n) :") + if(choice =='n'): + break \ No newline at end of file diff --git a/fileHandling/read_binary_file.py b/fileHandling/read_binary_file.py new file mode 100644 index 0000000..17df838 --- /dev/null +++ b/fileHandling/read_binary_file.py @@ -0,0 +1,9 @@ +#program to read a binary file of records - Just like structure +# made by : rakesh kumar +# Compiled on : 8-July-2018 + +import pickle +file = open("student.dat","rb") +list = pickle.load(file) +print(list) +file.close() \ No newline at end of file diff --git a/matplotlib/bar_Graph.py b/matplotlib/bar_Graph.py new file mode 100644 index 0000000..57a94a2 --- /dev/null +++ b/matplotlib/bar_Graph.py @@ -0,0 +1,9 @@ +# program to print scatter graph on the screen +# made by : rakesh kumar + +import matplotlib.pyplot as plt +import numpy as np +x = ['Delhi','Banglore','Chennai','Pune'] +y = [250,300,260,400] +plt.bar(x,y) +plt.show() \ No newline at end of file diff --git a/matplotlib/line_graph.py b/matplotlib/line_graph.py new file mode 100644 index 0000000..1271357 --- /dev/null +++ b/matplotlib/line_graph.py @@ -0,0 +1,9 @@ +# program to print scatter graph on the screen +# made by : rakesh kumar + +import matplotlib.pyplot as plt +import numpy as np +x = ['Delhi','Banglore','Chennai','Pune'] +y = [250,300,260,400] +plt.plot(x,y) +plt.show() \ No newline at end of file diff --git a/matplotlib/pie_graph.py b/matplotlib/pie_graph.py new file mode 100644 index 0000000..d03c5b1 --- /dev/null +++ b/matplotlib/pie_graph.py @@ -0,0 +1,9 @@ +# program to print scatter graph on the screen +# made by : rakesh kumar + +import matplotlib.pyplot as plt +import numpy as np +x = ['Delhi','Banglore','Chennai','Pune'] +y = [250,300,260,400] +plt.pie(y,labels= x) +plt.show() \ No newline at end of file diff --git a/matplotlib/scatter_graph.py b/matplotlib/scatter_graph.py new file mode 100644 index 0000000..df9b1a4 --- /dev/null +++ b/matplotlib/scatter_graph.py @@ -0,0 +1,6 @@ +import matplotlib.pyplot as plt +import numpy as np +x = ['Delhi','Banglore','Chennai','Pune'] +y = [250,300,260,400] +plt.scatter(x,y) +plt.show() \ No newline at end of file diff --git a/student.dat b/student.dat new file mode 100644 index 0000000..6ccc16c Binary files /dev/null and b/student.dat differ diff --git a/webscraper/imagedownloader.py b/webscraper/imagedownloader.py index aabe4bd..3e85584 100644 --- a/webscraper/imagedownloader.py +++ b/webscraper/imagedownloader.py @@ -28,24 +28,25 @@ def downloader(image_url,path): address = "https://www.pexels.com/search/{}".format(query) #webbrowser.open(address) -root = tk.Tk() -root.withdraw() -directory = filedialog.askdirectory() +if __name__ == '__main__': + root = tk.Tk() + root.withdraw() + directory = filedialog.askdirectory() -r = requests.get(address) -data = r.text -soup = BeautifulSoup(data,"html.parser") -for link in soup.select('.js-photo-link img'): - name = link.get('srcset') - len = (name.find('?')) - newname = name[0:len] - print(newname) - #webbrowser.open(newname) - downloader(newname,directory) -print("Download complete check your folder") -#root = tk.Tk() -#root.withdraw() -#directory = filedialog.askdirectory() #source folder + r = requests.get(address) + data = r.text + soup = BeautifulSoup(data,"html.parser") + for link in soup.select('.js-photo-link img'): + name = link.get('srcset') + len = (name.find('?')) + newname = name[0:len] + print(newname) + #webbrowser.open(newname) + downloader(newname,directory) + print("Download complete check your folder") + #root = tk.Tk() + #root.withdraw() + #directory = filedialog.askdirectory() #source folder -#url ="http://www.binarynote.com/wp-content/themes/binarynote3/images/main.jpg" -#downloader(link.get(srcset,directory)) \ No newline at end of file + #url ="http://www.binarynote.com/wp-content/themes/binarynote3/images/main.jpg" + #downloader(link.get(srcset,directory)) \ No newline at end of file diff --git a/webscraper/wikipedia.py b/webscraper/wikipedia.py new file mode 100644 index 0000000..1986554 --- /dev/null +++ b/webscraper/wikipedia.py @@ -0,0 +1,12 @@ +# python program to download wikipedia page +# made by : rakesh kumar + + +import requests +req = requests.post('https://binarynote.com', data = {'search':'wordpress'}) +req.raise_for_status() +with open('wordpress.html', 'wb') as fd: + for chunk in req.iter_content(chunk_size=50000): + fd.write(chunk) + +print("File generated...") \ No newline at end of file