Huge omega thanks to @wasif for emailing me this challenge idea in its basic form
Everyone knows that questions on StackExchange require tags - labels that allow posts to be grouped together by category. However, most of the time, I barely know which tags exist, because there's just so many of them. Henceforth, today's task is to tell me every single tag that exists on the Code Golf and Coding Challenges Stack Exchange.
The Challenge
Write a program or function that prints/returns a list of all available tags on https://codegolf.stackexchange.com As tags can be created/deleted at any time, simply hard-coding a list of tags is not a valid solution - the list must be correct at run-time regardless of when the program/function is executed. The tags avaliable can be seen here
Rules
- As this is an internet challenge, internet connections are allowed. However, web requests can only be made to codegolf.stackexchange.com and api.stackexchange.com domains.
- Output can be given in any convenient and reasonable format.
- The tags can be in any order, so long as all current tags are returned.
- The exact name of the tags must be used (e.g.
code-golf
is valid,code GOLF
is not valid.) - And as usual, standard loopholes apply, shortest code wins
Example Program
import urllib.request
import regex
pobj = regex.compile('rel="tag">(.*)</a>')
page_number = 2
req = urllib.request.urlopen(f"https://codegolf.stackexchange.com/tags?page=1&tab=name")
data = req.read().decode('utf-8')
tags = []
while data.count("tag") != 43:
tags += pobj.findall(data)
req = urllib.request.urlopen(f"https://codegolf.stackexchange.com/tags?page={page_number}&tab=name")
data = req.read().decode('utf-8')
page_number += 1
print(tags)