I am new to Python and been trying to learn both Python and BeautifulSoup.
How would I incorporate the href links as other "key":"value" into a JSON object:
import json
html = """<table>
<tbody>
<tr>
<td><a href="/page/some-page">Some Page Title</a></td>
<td class="created-at">2020-08-01</td>
<td><a href="/id/400">Text Description 1</a></td>
</tr>
<tr>
<td><a href="/page/some-page-2">Some Page Title 2</a></td>
<td class="created-at">2020-08-02</td>
<td><a href="/id/400">Text Description 2</a></td>
</tr>
<tr>
<td><a href="/page/some-page-3">Some Page Title 3</a></td>
<td class="created-at">2020-08-03</td>
<td><a href="/id/400">Text Description 3</a></td>
</tr>
</tbody>
</table>"""
data = []
soup = BeautifulSoup(html, 'html.parser')
rows = soup.select('table > tbody > tr')
for table in rows:
keys = ["Name","Date","Description"]
values = [td.get_text(strip=True) for td in table.find_all('td')]
d = dict(zip(keys, values))
data.append(d)
print(json.dumps(data, indent=4))