Skip to content

Instantly share code, notes, and snippets.

@kyouheicf
Last active November 9, 2021 15:42
Show Gist options
  • Save kyouheicf/be7ad550b933a7b897d90abf919c12da to your computer and use it in GitHub Desktop.
Save kyouheicf/be7ad550b933a7b897d90abf919c12da to your computer and use it in GitHub Desktop.
This script is intended to be used in order to add extra api call to python-cloudlare. You can do it through "python3 list_cf_api_endpoint.py >> ~/.cloudflare/cloudflare.cfg".
# Import Library
from bs4 import BeautifulSoup
import urllib.request
# Set URL
url = "https://api.cloudflare.com/"
# Retrieve from URL
html = urllib.request.urlopen(url)
# Use BeautifulSoup
soup = BeautifulSoup(html, "html.parser")
# Retrieve the list of API endpoint
list_of_endpoints = []
for e in soup.find_all('pre',class_='language-http'):
list_of_endpoints.append(e.get_text().split()[-1])
#list_of_endpoints.sort()
#for e in list_of_endpoints:
# print(e)
# Get and show the unique value of the list above
list_of_unique_endpoints = list(set(list_of_endpoints))
list_of_unique_endpoints.remove('object/:object_id')
list_of_unique_endpoints.sort()
for e in list_of_unique_endpoints:
print(' /client/v4/' + e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment