Reputation: 653
I have a list of products that I would like to search in the following website bb farma
. Ideally when inserting a product the search comes out with a list of medicines in a table as in the picture below:
Now, the aim is to make a search in Python (with BeautifulSoup I guess) for each product I have stored in a list and save the number called ATC in the table if the search is successful (e.g. with a try and an except).
The html when inspecting the page is the following:
Alternatively, maybe I could parse the table tab directly.
Thanks a lot
Upvotes: 0
Views: 70
Reputation: 84
url = 'Whatever URL'
def get_list():
s = BeautifulSoup(url, 'lxml')
med_tags = s.findAll('td', 'class=small')
med_list = []
for med in med_tags:
try:
whatever = med.find('a').get('href')
med_list.append({
'whatever med': whatever
})
except:
print('Something did not work')
Upvotes: 0