-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-export.py
22 lines (19 loc) · 1000 Bytes
/
cli-export.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# cli-export
import requests, time, csv
from bs4 import BeautifulSoup
from urllib.request import urlopen
response = requests.get('https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html')
soup = BeautifulSoup(response.text, 'html.parser')
service = soup.find('div', class_='toctree-wrapper compound')
with open("cli-export.csv", "wt+", newline="") as f:
writer = csv.writer(f)
writer.writerow(["Service", "Actions"])
for anchor in service.find_all('a'):
link = anchor.get('href')
response = requests.get('https://awscli.amazonaws.com/v2/documentation/api/latest/reference/' + link)
soup2 = BeautifulSoup(response.text, 'html.parser')
service_link = link.replace('/index.html', '') # strips link and outputs service names
service_list = soup2.find_all("a", class_='reference internal')[4:]
for name in service_list:
serv_name = name.get_text()
writer.writerow([service_link, serv_name])