File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Email Feed
2
+
3
+ A script to find the link to unsusbscribe from a mail in the unread email inbox
4
+ It show unread gmail feed list that containt words like "unsusbscribe" , "Stop these mails" and contain urls.
5
+
6
+
7
+ ## Dependencies
8
+
9
+ Email Feed depends on third party libraries and you will first need to install the application's dependencies:
10
+
11
+ ``` bash
12
+ pip install -r requirements.txt
13
+ ```
14
+
15
+ ## Run Locally
16
+
17
+ Clone the project
18
+
19
+ ``` bash
20
+ git clone https://github.com/python-geeks/Automation-scripts.git
21
+ ```
22
+
23
+ Go to the project directory
24
+
25
+ ``` bash
26
+ cd Automation-scripts/email_feed
27
+ ```
28
+
29
+ Change email and pass
30
+
31
+
32
+ Run ``` gmail_feed.py ```
33
+
34
+ ``` python
35
+ python gmail_feed.py
36
+ ```
37
+
38
+
39
+ ## Output
40
+
41
+ It is a printable list
42
+
43
+
44
+ ## Author
45
+ https://github.com/JoaquinMontesinos
Original file line number Diff line number Diff line change
1
+ import xmltodict
2
+ import re
3
+ import requests
4
+
5
+ username = "xxx"
6
+ password = "xxx"
7
+
8
+ URL = 'https://%s:%s@mail.google.com/mail/u/0/feed/atom/all' % (username , password )
9
+ r = requests .get (URL )
10
+
11
+ if r .status_code == 401 :
12
+ print ("login [%s] or password [%s] is incorrect\n %s" % (username , password , 'Error' ))
13
+ elif r .status_code != 200 :
14
+ print ("Requests error [%s] - %s" % (r .status_code , URL ))
15
+ elif r .status_code == 200 :
16
+ contents = r .text
17
+ a = xmltodict .parse (contents )
18
+ for k in range (len (a ['feed' ]['entry' ])):
19
+ text = a ['feed' ]['entry' ][k ]['summary' ]
20
+ key_words1 = re .findall ('unsusbscribe' , text )
21
+ key_words2 = re .findall ('Stop these mails' , text )
22
+ keys = key_words1 + key_words2
23
+ urls = re .findall (r'''(?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-&?=%.]+''' , text )
24
+ if len (keys ) > 0 and len (urls ) > 0 :
25
+ print (a ['feed' ]['entry' ][k ]['title' ])
26
+ print (a ['feed' ]['entry' ][k ]['summary' ][0 :50 ])
27
+ print (a ['feed' ]['entry' ][k ]['author' ]['email' ])
28
+ print (urls )
29
+ print ('----------' )
Original file line number Diff line number Diff line change
1
+ xmltodict
2
+ requests
You can’t perform that action at this time.
0 commit comments