I am trying to extract the description, date and url from the table in the following page:
https://www.fda.gov/safety/recalls-market-withdrawals-safety-alerts
For my code to be consistent with 20 other url's I need to have the logic of below i.e. findall of the whole body and then loop through it to find the applicable data.
The problem is that the table body is null.
import requests
from bs4 import BeautifulSoup
r = requests.get("https://www.fda.gov/safety/recalls-market-withdrawals-safety-alerts")
c = r.content
soup = BeautifulSoup(c,"html.parser")
all = soup.find_all("tbody") #whole table text THIS IS WHERE THE PROBLEM ORIGINATES
for item in all:
print(item.find_all("tr").text) #test for tr text i.e. product description
print(item.find("a")["href"]) #url
print(item.find_all("td")[0].text) #date (won't work but can't test until tbody returns data
What am I doing wrong?
Thanks in advance!