fork download
  1. # your code goes here
  2. import requests
  3. from bs4 import BeautifulSoup
  4. import time
  5. from random import randint
  6.  
  7. def lineNotifyMessage(token, msg):
  8. headers = {
  9. "Authorization": "Bearer " + token,
  10. "Content-Type" : "application/x-www-form-urlencoded"
  11. }
  12. payload = {'message': msg}
  13. r = requests.post("https://n...content-available-to-author-only...e.me/api/notify", headers = headers, params = payload)
  14. return r.status_code
  15.  
  16. token = 'my token'
  17. message = '有票RRR'
  18. URL = "https://w...content-available-to-author-only...t.cc/bbs/Drama-Ticket/index.html"
  19. lastOne = ""
  20.  
  21. while True:
  22. response = requests.get(URL)
  23. soup = BeautifulSoup(response.text, 'html.parser')
  24.  
  25. titles = soup.find_all('div', {'class': 'title'})
  26.  
  27. for title in titles[-5::-1]:
  28. if title == lastOne:
  29. break
  30.  
  31. if '五月天' in title.text and '售' in title.text:
  32. lineNotifyMessage(token,message+title.text)
  33. print(title.text)
  34.  
  35. lastOne = titles[-5]
  36.  
  37. waiting_times = 30+randint(0,40)
  38. print(waiting_times)
  39. time.sleep(waiting_times)
  40.  
Runtime error #stdin #stdout #stderr 0.34s 34184KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 3, in <module>
ModuleNotFoundError: No module named 'bs4'