Advertisement
flwkjlwekjfs

Untitled

Jul 4th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import socket
  2. import string
  3. import requests
  4. import json
  5. import urllib.request
  6. from html import unescape
  7. import re
  8.  
  9. def eightball( name, message ):
  10. url = "http://8ball.delegator.com/magic/JSON/"
  11. req = urllib.request.urlopen(url+message)
  12. #resp = req.read()
  13. #data = json.loads(resp.decode('utf8'))
  14. #say( name, data['magic']['answer'] )
  15.  
  16. eightball('dave', 'is it a good day')
  17.  
  18.  
  19.  
  20. [user@valhalla python3_random]$ python3.6 test.py
  21. Traceback (most recent call last):
  22. File "test.py", line 16, in <module>
  23. eightball('dave', 'is it a good day')
  24. File "test.py", line 11, in eightball
  25. req = urllib.request.urlopen(url+message)
  26. File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
  27. return opener.open(url, data, timeout)
  28. File "/usr/lib64/python3.6/urllib/request.py", line 532, in open
  29. response = meth(req, response)
  30. File "/usr/lib64/python3.6/urllib/request.py", line 642, in http_response
  31. 'http', request, response, code, msg, hdrs)
  32. File "/usr/lib64/python3.6/urllib/request.py", line 570, in error
  33. return self._call_chain(*args)
  34. File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
  35. result = func(*args)
  36. File "/usr/lib64/python3.6/urllib/request.py", line 650, in http_error_default
  37. raise HTTPError(req.full_url, code, msg, hdrs, fp)
  38. urllib.error.HTTPError: HTTP Error 403: Forbidden
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement