from bs4 import BeautifulSoup import requests import re import csv results = {} URL = "https://product-security.pages.redhat.com/offering-registry/" r = requests.get(URL) soup = BeautifulSoup(r.text, 'html.parser') table = soup.find("table") rows = table.findAll("tr") for row in rows: for elem in row.contents: if row.contents[1].text == 'Offering': break else: # We extract the short name of the URL re_search = re.search('/offering-registry/offerings/(.*)/', row.contents[1].contents[0].attrs["href"]) results[re_search.group(1)] = row.contents[1].contents[0].text break print(results) with open('offerings.csv', 'w') as csv_file: writer = csv.writer(csv_file) for key, value in results.items(): writer.writerow([key, value])