Skip to content

Commit

Permalink
修复“阿里邮箱”bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kangvcar committed Jul 17, 2020
1 parent 6437f0d commit 2f59724
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
*.xlsx
*.swp
data
.idea
.idea
*.log
__pycache__
10 changes: 9 additions & 1 deletion Spiders/mail/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def write_json(self, name, str):
with open(name, 'w') as f:
f.write(str)

## 爬取QQ邮箱
def qq_mail(self, cookie, sid):
self.path = askdirectory(title='选择信息保存文件夹')
if str(self.path) == "":
Expand Down Expand Up @@ -81,6 +82,7 @@ def qq_mail(self, cookie, sid):
self.write_json(self.path + os.sep + 'qqmail_' + str(pn) + '.json', json.dumps(json_list))
# break

## 爬取新浪邮箱
def sinamail(self, cookie):
self.path = askdirectory(title='选择信息保存文件夹')
if str(self.path) == "":
Expand Down Expand Up @@ -134,6 +136,7 @@ def gen_driver(self, cookies_list):
except Exception as e:
print(e)

## 爬取hotmail/outlook邮箱
def get_hotmail(self, cookie_list):
self.path = askdirectory(title='选择信息保存文件夹')
if str(self.path) == "":
Expand All @@ -160,7 +163,11 @@ def get_hotmail(self, cookie_list):
continue
self.write_json(self.path + os.sep + 'hotmail.json', json.dumps(json_list))

## 爬取阿里邮箱
def get_aliyun_mail(self, cookie):
self.path = askdirectory(title='选择信息保存文件夹')
if str(self.path) == "":
sys.exit(1)
self.gen_session(cookie)
h = {
'Host': 'mail.aliyun.com',
Expand All @@ -184,8 +191,9 @@ def get_aliyun_mail(self, cookie):
url = 'https://mail.aliyun.com/alimail/ajax/mail/queryMailList.txt'
resp = self.session.post(url, headers=h, data=data)
obj_list = json.loads(resp.content.decode())['dataList']
self.write_json('aliyun_mail.json', json.dumps(obj_list))
self.write_json(self.path + os.sep + 'aliyun_mail.json', json.dumps(obj_list))

## 爬取网易邮箱
def get_wangyi(self, cookie):
self.path = askdirectory(title='选择信息保存文件夹')
if str(self.path) == "":
Expand Down
91 changes: 90 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
- [x] 新浪邮箱
- [x] Hotmail邮箱
- [x] Outlook邮箱
- [ ] 阿里邮箱
- [x] 阿里邮箱
- [ ] 12306
- [ ] 公积金
- [ ] 学信网
Expand Down Expand Up @@ -739,6 +739,95 @@
</details>


****
## 阿里邮箱

!> **说明**:需登录账号.

### 使用步骤

1. 点击**阿里邮箱**数据源按钮

![alimail1.png](https://i.loli.net/2020/07/17/Cdt7lAqIS1BFHaQ.png ':size=10%')

2. 在弹出的浏览器中登录阿里邮箱

![alimail2.png](https://i.loli.net/2020/07/17/hoki6tIlfeqa2yj.png ':size=50%')

3. 选择数据保存路径

![alimail3.png](https://i.loli.net/2020/07/17/YEr41OUX7lKJ5Vy.png ':size=50%')

4. 查看爬取的数据 (json格式)

![alimail4.png](https://i.loli.net/2020/07/17/6v2frAw9XPtO3E4.png ':size=50%')

### 数据说明

?> 👍 由于数据信息过长, 这里只作主要数据项说明, **点击展开查看示例**

<details>
<summary>aliyun_mail.json 👉 你的阿里邮箱所有邮件</summary>

```json
[
{
"clientExtraInfo": {
"avatarRcp": {
"clientExtraInfo": {},
"displayEmail": "***@gmail.com",
"displayName": " *** ",
"email": "***@gmail.com",
"encDisplayEmail": "***@gmail.com",
"encDisplayName": "***",
"name": "****"
},
"encFullDisplayTime": "2020\u5e747\u670817\u65e5(\u661f\u671f\u4e94) 15:14",
"displaySize": "3KB",
"encDisplayTime": "15:14",
"encRcpLineContent": "*****"
},
"encSubject": "13",
"encSummary": "13",
"folderId": "2",
"from": {
"clientExtraInfo": {},
"displayEmail": "***@gmail.com",
"displayName": "***",
"email": "***@gmail.com",
"encDisplayEmail": "***@gmail.com",
"encDisplayName": "*****",
"name": "******"
},
"id": "DzzzzyUvf-h$---112z7wiM",
"mailId": "2_0:DzzzzyUvf-h$---112z7wiM",
"markedSubject": "13",
"owner": "***@aliyun.com",
"saveToSendFolder": true,
"separatedSend": false,
"sessionId": "DzzzzyUvf-h---112wtmq3",
"status": 4,
"subject": "13",
"tagList": [],
"timestamp": 1594970066000,
"to": [
{
"clientExtraInfo": {},
"displayEmail": "***@aliyun.com",
"displayName": "",
"email": "***@aliyun.com",
"encDisplayEmail": "****@aliyun.com",
"encDisplayName": "",
"name": ""
}
]
},
...
]
```

</details>

****
## 中国联通

Expand Down
11 changes: 4 additions & 7 deletions tools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,6 @@ def OnClick(self, event):
# sid = re.findall('sid=(\w+)&?', self.driver.current_url)[0]
from urllib import parse
sid = parse.parse_qs(parse.urlparse(self.driver.current_url).query)['sid'][0]
# sid = 'svj8Q-vN5z8vd0cY'
print(cookie_str)
print(sid)
break
try:
y = YSpider()
Expand All @@ -451,14 +448,13 @@ def OnClick(self, event):
while 1:
time.sleep(0.2)
if self.driver.current_url != url:
# self.driver.minimize_window()
self.driver.minimize_window()
get_cookies = self.driver.get_cookies()
cookie_str = ''
for s in get_cookies:
cookie_str = cookie_str + s['name'] + '=' + s['value'] + ';'
break
try:
# self.SetStatusText("爬取中...", 3)
y = YSpider()
t = threading.Thread(target=y.get_aliyun_mail, args=(cookie_str,))
t.start()
Expand Down Expand Up @@ -814,9 +810,10 @@ def __init__(self, *args, **kw):
YidongButton(self, self.pnl, Item(start_x +xstep, start_y+ystep*2, '移动', 'resource/icon/yidong.png'))
LiantongButton(self, self.pnl, Item(start_x +xstep*2, start_y+ystep*2, '联通', 'resource/icon/liantong.png'))
DianxingButton(self, self.pnl, Item(start_x +xstep*3, start_y+ystep*2, '电信', 'resource/icon/dianxin.png'))
GjjButton(self, self.pnl, Item(start_x +xstep*4, start_y+ystep*2, '公积金', 'resource/icon/gjj.png'))
AlimailButton(self, self.pnl, Item(start_x+xstep*4, start_y+ystep*2, '阿里邮箱', 'resource/icon/alimail.png'))
# GjjButton(self, self.pnl, Item(start_x +xstep*4, start_y+ystep*2, '公积金', 'resource/icon/gjj.png'))
BilibiliButton(self, self.pnl, Item(start_x+xstep*5, start_y+ystep*2, '哔哩哔哩', 'resource/icon/bilibili.png'))
# AlimailButton(self, self.pnl, Item(start_x+xstep*5, start_y+ystep*2, '阿里邮箱', 'resource/icon/alimail.png'))

## row 4
CloudmusicButton(self, self.pnl, Item(start_x, start_y+ystep*3, '网易云音乐', 'resource/icon/netease_cloudmusic.png'))
XlmailButton(self, self.pnl, Item(start_x+xstep, start_y+ystep*3, '新浪邮箱', 'resource/icon/sina.png'))
Expand Down
Binary file modified tools/resource/icon/alimail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tools/resource/icon/alipay.png
Binary file not shown.

0 comments on commit 2f59724

Please sign in to comment.