fork download
  1. from bs4 import BeautifulSoup
  2. import requests
  3. from PIL import Image, ImageDraw
  4.  
  5. #爬蟲部分
  6. baha = 'https://f...content-available-to-author-only...m.tw/C.php?bsn=60076&snA=4893003&tnum=21'
  7. res = requests.get(baha, timeout=30)
  8. soup = BeautifulSoup(res.text, 'html.parser')
  9. tosearch = 'c-article content-edit'
  10. tags = soup.find_all(class_=tosearch)
  11. word = str(tags[0])[75:90]
  12. num = 0
  13. i = 0
  14. for i in range(len(word)):
  15. if((word[i]>='0')&(word[i]<='9')):
  16. num=num*10+int(word[i])-int('0')
  17. num=65535-(num-1)
  18.  
  19. #製圖部分
  20. img = Image.new("RGB", (33, 16))
  21. draw = ImageDraw.Draw (img)
  22. Font=("bold", 14)
  23. draw.text((1,2),str(num))
  24. img.save("thenum.png")
  25. img.show()
Runtime error #stdin #stdout #stderr 0.11s 119488KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 2, in <module>
ImportError: No module named 'requests'