You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
826 B

  1. # Python
  2. If you are already using the requests library, it's convenient to also use it here:
  3. ```python
  4. # using requests:
  5. import requests
  6. requests.get("PING_URL")
  7. ```
  8. Otherwise, you can use the urllib standard module.
  9. ```python
  10. # urllib with python 3.x:
  11. import urllib.request
  12. urllib.request.urlopen("PING_URL")
  13. ```
  14. ```python
  15. # urllib with python 2.x:
  16. import urllib
  17. urllib.urlopen("PING_URL")
  18. ```
  19. You can include additional diagnostic information in the in the request body (for POST requests), or in the "User-Agent" request header:
  20. ```python
  21. # Passing diagnostic information in the POST body:
  22. import requests
  23. requests.post("PING_URL", data="temperature=-7")
  24. ```
  25. ```python
  26. # Passing diagnostic information in the User-Agent header:
  27. import requests
  28. requests.get("PING_URL", headers={"User-Agent": "temperature=-7"})
  29. ```