Created
January 30, 2021 02:23
-
-
Save allyunion/1c006914f471fdc366273eec4b0e669c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
In [1]: import requests | |
In [2]: url = 'https://releases.hashicorp.com/terraform/' | |
In [3]: page = requests.get(url) | |
In [6]: from bs4 import BeautifulSoup as bs | |
In [7]: soup = bs(page.text, 'html.parser') | |
In [29]: for link in soup.find_all('a'): | |
...: if 'terraform' in link.text: | |
...: version = link.text.replace('terraform_', '') | |
...: subpage_url = str(urllib.parse.urljoin(url, link.get('href'))) + link.text + '_SHA256SUMS' | |
...: subpage = requests.get(subpage_url) | |
...: for line in subpage.text.split('\n'): | |
...: if 'linux_amd64' in line: | |
...: data[version] = 'sha256=' + line.split()[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment