def add_afsc_links(full_afsc_dict, reddit):
"""
Add links to /r/AirForce wiki from given filename into the dictionary.
:param dict: either enlisted_dict or officer_dict
:param reddit: PRAW reddit object
"""
# gets dict of AFSC to link on /r/AirForce wiki
wiki_page = reddit.subreddit("AirForce").wiki["index"]
wiki_soup = BeautifulSoup(wiki_page.content_html, "html.parser")
links = wiki_soup.find_all("a")
# currently all wiki AFSC are enlisted
for link in links:
# not all links have /r/AirForce/wiki/jobs so this is more generalized
# using only /r/AirForce/ wiki links
if "www.reddit.com/r/AirForce/wiki/" in link["href"]:
AFSC_code = link["href"].split("/")[-1].upper()
base_afsc = AFSC_code[:5] # shaves off any prefixes
if base_afsc in full_afsc_dict["enlisted"].keys():
full_afsc_dict["enlisted"][base_afsc]["link"] = link["href"]
评论列表
文章目录