步骤
效果如下
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/8b7a377e243488fd2e1b7bbd41268352.png)
代码
from lxml import etree
from urllib.request import urlopen
import urllib
import itchat as ic
url = 'http://dict.eudic.net/home/dailysentence'
req = urllib.request.Request(url)
html = urlopen(req).read()
html = etree.HTML(html)
result = html.xpath('.//div[@id="senten_move"]/p/text()')
english = result[0]
chinese = result[1]
all = '每日一句:\n' + english + '\n' + chinese
ic.auto_login()
name = input()
friends = ic.search_friends(name)
friendName = friends[0]['UserName']
ic.send(all, friendName)