Skip to content

Commit

Permalink
some more python programs
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Jul 29, 2019
1 parent dc4504f commit c88dcc7
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 4 deletions.
4 changes: 4 additions & 0 deletions DataStructure/merge_python_way.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
x =[1,2,3,4,5,6,7,8]
y = [1,2,3,4,5]
z= x+y
print(z)
47 changes: 47 additions & 0 deletions Email/spam_Words.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import imapclient # use pip install imapclient <- easy for reading different email Server
import pyzmail # easy to read different part of EMail like subject / body /cc/bcc/to/from etc
from collections import Counter

d=[]
imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True) # email server for Gmail
username=input("Enter your completer gmail User Name ")
Password=input("Enter your gmail passowrd")
imapObj.login(username,Password) # login Method for your email
print("Dear", username," you are logged into your account")
imapObj.select_folder('[Gmail]/Spam', readonly=True) # selecting different folder for phising email i used Spam
UIDs = imapObj.search(['ALL']) # different filter for mailboxes ALL/SEEN/UNSEEN it returns ids for the filter you have search
print( "No of emails in your [Gmail]/Spam' box=" ,len(UIDs))
print("Mail from\t\t"," Subject Line")
for i in UIDs: # only 10 emails to be taken
rawMessages = imapObj.fetch([i], ['BODY[]', 'FLAGS']) # fetch the email message for particular UID
message = pyzmail.PyzMessage.factory(rawMessages[i][b'BODY[]']) # Parse the raw email message.
print(message.get_addresses('from'),message.get_subject()) # return the subject part of email
message.text_part != None # check for text part of body message Message can have html part also
d.append(message.text_part.get_payload().decode(message.text_part.charset)+"\n") # fetch the textpart
#get_payload() method that returns the email’s body as a value of the bytes data type But this still isn’t a string value that we can use.
#decode() method takes one argument: the message’s character encoding,
#stored in the text_part.charset or html_part.charset attribute. This, finally, will return the string of the email’s body.
imapObj.logout()
print("Logged out successfully from server...")

with open("E:\email2.txt", 'w') as fp:
for i in range(len(d)):
fp.write(str(d[i]))


file = open("E:\email2.txt")
split_it=[]
for line in file:
line=line.strip()
split_it+=line.split() # split() returns list of all the words in the string


# Pass the split_it list to instance of Counter class.
Counter = Counter(split_it)
# most_common() produces k frequently encountered
# input values and their respective counts.
print( "most common word found in EMails")
num=int(input("How many most common words you want to find"))
most_occur = Counter.most_common(num)
for com in most_occur:
print(com[0],"=>",com[1])
16 changes: 16 additions & 0 deletions Loops/anagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# program to find out all anagram of given word
# made by : rakesh kumar

from itertools import permutations

def words(letters):
yield from map(''.join, permutations(letters, len(letters)))

result = set()
for word in words('Compute'):
result.add(word)

print(f' There are {len(result)} combinations')
print(result)


2 changes: 1 addition & 1 deletion add.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
d= 10
a= a+2
b = b-20
a= c-30
a= b-30
print(a)
Empty file added webscraper/whatsappmsg.py
Empty file.
6 changes: 3 additions & 3 deletions webscraper/youtubeDownloader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import youtube_dl
import urllib
import shutil
# import urllib
# import shutil
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=a8aDcLk4vRc&list=PLeo1K3hjS3uset9zIVzJWqplaWBiacTEU&index=2'])
ydl.download(['https://www.youtube.com/watch?v=N5vscPTWKOk'])

0 comments on commit c88dcc7

Please sign in to comment.