龙空技术网

Python抓取实时黄金数据微信通知到微信手机助手

Fly6 93

前言:

现在我们对“python 推送消息到手机”大约比较注意,姐妹们都需要了解一些“python 推送消息到手机”的相关知识。那么小编在网摘上收集了一些对于“python 推送消息到手机””的相关资讯,希望我们能喜欢,看官们一起来了解一下吧!

from bs4 import BeautifulSoupimport urllib.requestfrom time import sleepfrom datetime import datetimeimport sslimport itchatdef sendMessage():    # 产生二维码    itchat.auto_login(hotReload = True)def getGoldPrice():    user_agent = 'Mozilla/4.4 (compatible; MSIE 5.5; Windows NT)'    headers = {'User-Agent': user_agent}    context = ssl._create_unverified_context()    #url = ";    sNow1 = datetime.now().strftime("%H:%M:%S")    url=";+sNow1    req = urllib.request.Request(url, None, headers)    response = urllib.request.urlopen(req)    page = response.read()    return page.decode('gbk')with open("goldPrice.out", "w") as f:    sendMessage()    for x in range(0, 60):        sNow = datetime.now().strftime("%H:%M:%S")        f.write("{0},{1} \n".format(sNow, getGoldPrice()))        print("{0},{1} \n".format(sNow, getGoldPrice()))        itchat.send(getGoldPrice(), toUserName='filehelper')        sleep(59)

标签: #python 推送消息到手机