add drug dosages parsing, add postgres db
This commit is contained in:
parent
c218e0bbf3
commit
4a59ba5f4a
15 changed files with 856 additions and 122 deletions
|
|
@ -87,13 +87,18 @@ class DrugPriceParser:
|
|||
dosages_table = formulation.find_next('div')
|
||||
dosage_elements = dosages_table.find_all('details')
|
||||
for dosage in dosage_elements:
|
||||
quantity_table = dosage.find('table')
|
||||
quantity_row = quantity_table.find_all('td', {'class': 'ddc-text-right'})
|
||||
price_per_unit = quantity_row[0].get_text()
|
||||
price_per_unit = price_per_unit.split(" ")[0]
|
||||
|
||||
summary = dosage.find('summary')
|
||||
spans = summary.find_all('span')
|
||||
dosage_name = spans[0].find('b').get_text()
|
||||
dosage_price = spans[1].find_next('b').get_text()
|
||||
# dosage_price = spans[1].find_next('b').get_text()
|
||||
dosages.append(Dosage(
|
||||
name=dosage_name.rstrip(),
|
||||
price=float(dosage_price.rstrip().replace('$', '').replace(',', ''))
|
||||
price=float(price_per_unit.rstrip().replace('$', '').replace(',', ''))
|
||||
))
|
||||
formulations.append(Formulation(
|
||||
name=formulation_name.rstrip(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue