def auto_reply(msg): import requests response = requests.get(msg.url) document = PyQuery(response.text) content = document('#js_content').text() msg1 = a(content,100) return msg1
def auto_reply(msg): import requests from pyquery import PyQuery #r = requests.get('https://api.github.com/user', auth=('user', 'pass')) 官方事例 response = requests.get(msg.url) document = PyQuery(response.text) content = document('#js_content').text() from mymodule.stats_word import stats_text as a msg1 = a(content, 100) return msg1
def auto_reply(msg): import requests from pyquery import PyQuery #r = requests.get('https://api.github.com/user', auth=('user', 'pass')) 官方事例 response = requests.get(msg.url) document = PyQuery(response.text) content = document('#js_content').text() from mymodule.stats_word import stats_text as a msg1 = dict(a(content,20)) import numpy as np import matplotlib.pyplot as plt import matplotlib.font_manager as fm import pandas as pd from pandas import DataFrame,Series plt.rcParams['font.sans-serif']=['SimHei'] group_x = list(msg1.keys()) group_y = list(msg1.values()) df = pd.DataFrame(group_y,index = group_x) df.plot(kind = 'barh') plt.savefig('day13.png') msg.reply_image('day13.png')
def auto_reply(msg): import requests from pyquery import PyQuery #r = requests.get('https://api.github.com/user', auth=('user', 'pass')) 官方示例 response = requests.get(msg.url) document = PyQuery(response.text) content = document('#js_content').text() from mymodule.stats_word import stats_text as a msg1 = dict(a(content, 20)) import numpy as np import matplotlib.pyplot as plt import matplotlib.font_manager as fm #為了顯示中文替換字體 import pandas as pd #Pandas 提供兩種主要的資料結構,Series 與 DataFrame。Series 顧名思義就是用來處理時間序列相關的資料(如感測器資料等),主要為建立索引的一維陣列。DataFrame 則是用來處理結構化(Table like)的資料,有列索引與欄標籤的二維資料集,例如關聯式資料庫、CSV 等等。 from pandas import DataFrame, Series plt.rcParams['font.sans-serif'] = ['SimHei'] group_x = list(msg1.keys()) group_y = list(msg1.values()) df = pd.DataFrame(group_y, index=group_x) df.plot(kind='barh') plt.savefig('day13.png') msg.reply_image('day13.png') #將結果返回給發送消息的好友
import requests from pyquery import PyQuery #r = requests.get('https://api.github.com/user', auth=('user', 'pass')) 官方示例 response = requests.get('https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA') document = PyQuery(response.text) content = document('#js_content').text() from mymodule.stats_word import stats_text as a list1 = a(content, 100) str_1 = ' '.join(str(i) for i in list1) import getpass sender = input('輸入發件人郵箱:') password = getpass.getpass('輸入發輸入發件人郵箱密碼(可複制粘貼):') #When no password is given and the user is not found in the keyring, getpass.getpass() is used to prompt the user for a password. recipients = input('輸入收件人郵箱:') import yagmail #yagmail.SMTP('mygmailusername').send('*****@*****.**', 'subject', 'This is the body') #yag = yagmail.SMTP('mygmailusername', 'mygmailpassword') #yag.send('*****@*****.**', 'subject', contents) yag = yagmail.SMTP(user=sender, password=password, host='smtp.mail.yahoo.com') yag.send(recipients, '1901090011 DAY11 KHHsieh', contents=str_1)