-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95fbac6
commit a9d08f9
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea/* | ||
.idea/* | ||
readme/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ name = "pypi" | |
[packages] | ||
pycurl = "*" | ||
requests = "*" | ||
python-dotenv = "*" | ||
|
||
[dev-packages] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import requests | ||
import csv | ||
import json | ||
import os | ||
from dotenv import load_dotenv | ||
from datetime import datetime | ||
|
||
def get_categories(apikey): | ||
response = requests.get("https://dash.readme.com/api/v1/categories", auth=(apikey, "")) | ||
return response.json() | ||
|
||
def get_docs_for_category(apikey, slug): | ||
response = requests.get("https://dash.readme.com/api/v1/categories/{}/docs".format(slug), auth=(apikey, "")) | ||
return response.json() | ||
|
||
def get_doc(apikey, slug): | ||
response = requests.get("https://dash.readme.com/api/v1/docs/{}".format(slug), auth=(apikey, "")) | ||
doc = response.json() | ||
return doc | ||
|
||
def get_docs(): | ||
load_dotenv() | ||
apikey = os.getenv("APIKEY") | ||
docs_by_category = get_categories(apikey) | ||
for category in docs_by_category: | ||
print("**** Category: {} ****".format(category["title"])) | ||
category_docs = get_docs_for_category(apikey, category["slug"]) | ||
category["docs"] = category_docs | ||
for doc in category_docs: | ||
print("Doc: {}".format(doc["title"])) | ||
doc_details = get_doc(apikey, doc["slug"]) | ||
doc["details"] = doc_details | ||
if "children" in doc and len(doc["children"]) > 0: | ||
for child_doc in doc["children"]: | ||
print("Child doc: {}".format(child_doc["title"])) | ||
child_doc_details = get_doc(apikey, child_doc["slug"]) | ||
child_doc["details"] = child_doc_details | ||
|
||
# write json data to file | ||
# current time | ||
ct = datetime.now().strftime("%Y%m%d%H%M%S") | ||
f = open("{}_readme_docs.json".format(ct), "w") | ||
f.write(json.dumps(docs_by_category)) | ||
f.close() | ||
|
||
if __name__ == '__main__': | ||
get_docs() |