Created
December 22, 2018 20:05
-
-
Save dojutsu-user/f2954a852a936827eee3de6d1be07734 to your computer and use it in GitHub Desktop.
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
def get_org_projects_info(org_link): | |
"""Get organisation's projects information | |
:param org_link: Valid link to the organisation's info page of a specific year | |
:type org_link: str | |
:returns: A list of dictionaries of each project's title, descrition and link of project | |
:rtype: list | |
""" | |
response = get_response(org_link) | |
if response.ok: | |
soup = BeautifulSoup(response.text, 'html.parser') | |
projects_li = soup.find_all( | |
'li', 'mdl-list__item mdl-list__item--two-line') | |
project_info = [] | |
for proj_html in projects_li: | |
proj_info = {} | |
proj_title = proj_html.select('a')[0].text.replace('\n', '') | |
proj_desc = proj_html.select('span')[1].text.replace('\n', '') | |
proj_relative_link = proj_html.select('a')[0].get('href') | |
proj_full_link = HOME_PAGE + proj_relative_link | |
proj_info['title'] = proj_title | |
proj_info['description'] = proj_desc | |
proj_info['link'] = proj_full_link | |
project_info.append(proj_info) | |
return project_info | |
else: | |
print('Something Went Wrong') | |
print(f'Status Code: {response.status_code}') | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment