当前位置:   article > 正文

获取大麦网孟鹤堂演出数据并播报和在右下角弹窗提示_大麦演出id

大麦演出id

 

  1. #!/usr/bin/env python
  2. # coding=utf-8#!/usr/bin/env python
  3. # coding=utf-8
  4. # 获取大麦网孟鹤堂演出数据并播报和在右下角弹窗提示
  5. import requests
  6. import win32com.client
  7. from lxml import etree
  8. import json,time
  9. from show_msg import TestTaskbarIcon
  10. class Check():
  11. def __init__(self):
  12. self.speaker = win32com.client.Dispatch("SAPI.SpVOice")
  13. self.headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36"}
  14. self.damai_url = 'https://detail.damai.cn/item.htm?spm=' \
  15. 'a2oeg.search_category.0.0.a7036164RquLgS&id=592881382534&clicktitle=' \
  16. '%E5%AD%9F%E9%B9%A4%E5%A0%82%E7%9B%B8%E5%A3%B0%E4%B8%93%E5%9C%BA-%E5%A4%A9%E6%B4%A5%E7%AB%99'
  17. # 处理check
  18. def check(self,t):
  19. while True:
  20. print("-")
  21. time.sleep(2)
  22. response = requests.get(self.damai_url,headers=self.headers)
  23. html = etree.HTML(response.text)
  24. result = html.xpath('//div[@id="dataDefault"]/text()')[0]
  25. # with open("meng.html",'w',encoding='utf-8')as f:
  26. # f.write(response.text)
  27. dic_json = json.loads(result)
  28. # print((dic_json['performBases'][0]['performs'][0]['skuList'][1]['priceId']))
  29. dic = dic_json['performBases'][0]['performs'][0]['skuList']
  30. for i in range(0,4):
  31. sku = (dic[i])
  32. if sku['priceId'] == 220767038:
  33. if len(sku['promotionTags']) == 0:
  34. t.showMsg("280有货啦", "280")
  35. print("280有货啦")
  36. self.speaker.Speak('280有货啦') # 播报名字
  37. else:
  38. self.speaker.Speak('280无货') # 播报名字
  39. elif sku['priceId'] == 220775022:
  40. if len(sku['promotionTags']) == 0:
  41. t.showMsg("680有货啦", "680")
  42. print("680有货啦")
  43. self.speaker.Speak('680有货啦') # 播报名字
  44. else:
  45. self.speaker.Speak('680无货') # 播报名字
  46. elif sku['priceId'] == 220765017:
  47. if len(sku['promotionTags']) == 0:
  48. t.showMsg("880有货啦", "880")
  49. print("880有货啦")
  50. self.speaker.Speak('880有货啦') # 播报名字
  51. else:
  52. self.speaker.Speak('880无货') # 播报名字
  53. else:
  54. if len(sku['promotionTags']) == 0:
  55. t.showMsg("480有货啦", "480")
  56. print("480有货啦")
  57. self.speaker.Speak('480有货啦') # 播报名字
  58. else:
  59. self.speaker.Speak('480无货') # 播报名字
  60. if __name__ == "__main__":
  61. t = TestTaskbarIcon()
  62. ch = Check()
  63. ch.check(t)

弹窗模块show_msg.py:

  1. #!/usr/bin/env python
  2. # coding=utf-8
  3. # 在右下角进行弹窗提示
  4. import win32gui
  5. import win32con
  6. import time
  7. class TestTaskbarIcon:
  8. def __init__(self):
  9. # 注册一个窗口类
  10. wc = win32gui.WNDCLASS()
  11. hinst = wc.hInstance = win32gui.GetModuleHandle(None)
  12. wc.lpszClassName = "PythonTaskbarDemo"
  13. wc.lpfnWndProc = {win32con.WM_DESTROY: self.OnDestroy, }
  14. classAtom = win32gui.RegisterClass(wc)
  15. style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU
  16. self.hwnd = win32gui.CreateWindow(classAtom, "Taskbar Demo", style,
  17. 0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT,
  18. 0, 0, hinst, None)
  19. hicon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
  20. nid = (self.hwnd, 0, win32gui.NIF_ICON, win32con.WM_USER + 20, hicon, "Demo")
  21. win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, nid)
  22. def showMsg(self, title, msg):
  23. nid = (self.hwnd, # 句柄
  24. 0, # 托盘图标ID
  25. win32gui.NIF_INFO, # 标识
  26. 0, # 回调消息ID
  27. 0, # 托盘图标句柄
  28. "TestMessage", # 图标字符串
  29. msg, # 气球提示字符串
  30. 0, # 提示的显示时间
  31. title, # 提示标题
  32. win32gui.NIIF_INFO # 提示用到的图标
  33. )
  34. win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, nid)
  35. def OnDestroy(self, hwnd, msg, wparam, lparam):
  36. nid = (self.hwnd, 0)
  37. win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid)
  38. win32gui.PostQuitMessage(0) # Terminate the app.
  39. if __name__ == '__main__':
  40. t = TestTaskbarIcon()
  41. t.showMsg("您有新的文件,请登录查看", "Mr a2man!")
  42. # time.sleep(5)
  43. # win32gui.DestroyWindow(t.hwnd)

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/631765
推荐阅读
相关标签
  

闽ICP备14008679号