Skip to content

Instantly share code, notes, and snippets.

@gaxiiiiiiiiiiii
Last active August 28, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaxiiiiiiiiiiii/2e608352b7f10c943444e79e9326ae15 to your computer and use it in GitHub Desktop.
Save gaxiiiiiiiiiiii/2e608352b7f10c943444e79e9326ae15 to your computer and use it in GitHub Desktop.
def get_all_article():
# initialize
article_api = "https://alis.to/api/articles/recent?limit=100&page=%d"
result = []
page = 1
# データ取得
while True:
try:
raw_article_data = urlopen(article_api % page).read().decode("utf-8")
json_article_data = json.loads(raw_article_data)
articles_data = json_article_data["Items"]
result.extend(articles_data)
page += 1
except:
break
return result
def get_all_tags(all_articles):
all_tags = []
for article in all_articles:
if "tags" in article.keys():
tags = article["tags"]
all_tags.extend(tags)
all_tags =list( set(all_tags))
return all_tags
if __name__ == '__main__':
all_articles = get_all_article()
all_tags = get_all_tags(all_articles)
print(len(all_tags)
for tag in all_tags:
print(tag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment