Skip to content

Commit e9fbcdb

Browse files
authored
Merge pull request selfteaching#1132 from daweijian/master
19100102 day11 还是报错状态 先交一版作业
2 parents e707ac0 + f4e618d commit e9fbcdb

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import yagmail
2+
import requests
3+
import pyquery
4+
import stats_word
5+
import sys
6+
import getpass
7+
8+
9+
# r=requests.get('https://api.github.com/uder',auth=('user','pass'))
10+
# print(r.status_code)
11+
# print(r.headers['content-type'])
12+
# print(r.encoding)
13+
# print(r.text)
14+
# print(r.json())
15+
16+
#提取微信公众号文章正文
17+
r=requests.get('https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA',auth=('user','pass'))
18+
document=pyquery.PyQuery(r.text)
19+
content=document('#js_content').text()
20+
21+
#调用stats_word中的stats_text_cn函数统计词频
22+
mdict=[]
23+
strResult=''
24+
try:
25+
mdict=stats_word.stats_text_cn(content,100)
26+
except:
27+
print("error:",sys.exc_info()[0])
28+
29+
strResult=','.join([str(x) for x in mdict])
30+
#strResult='test'
31+
32+
#发送邮件
33+
sender=input('请输入发件人邮箱:')
34+
password=getpass.getpass('输入发件人邮箱密码(可复制粘贴):')
35+
recipients=input('请输入收件人邮箱:')
36+
37+
try:
38+
yag=yagmail.SMTP(sender,password,'smtp.mail.aliyun.com')
39+
#yag.send('[email protected]','subject',strResult)
40+
yag.send(recipients,'19100102 daweijian',strResult)
41+
print("已发送,请注意查收。")
42+
except:
43+
print("error:",sys.exc_info()[0])
44+

19100102/daweijian/mymodule/stats_word.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 封装d5的代码
22
import re
33
from collections import Counter
4-
4+
import string
55
import jieba
66

77

0 commit comments

Comments
 (0)