Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pip install MechanicalSoup
- import mechanicalsoup
- import sys
- distribution = "ubuntu"
- try:
- # Create a browser object
- br = mechanicalsoup.Browser()
- url = "https://distrowatch.com/table.php?distribution={}".format(distribution)
- page = br.get(url) # <Response [200]> # ok
- td = page.soup.find("td", class_='TablesTitle')
- title = td.h1.contents[0].strip() #ubuntu
- print("Distro: {}\n".format(title))
- last_update = td.div.contents[0].strip() # Last Update: 2019-02-19 21:20 UTC
- print("last update: {}\n".format(last_update))
- desc = td.ul.next_sibling.strip()
- print("description: {}\n".format(desc))
- except Exception as e:
- print("Error: {}".format(e))
- sys.exit()
Add Comment
Please, Sign In to add comment