How to dump data from python as JSON -
I have a python program that can extract information from HTML files but I have to leave it as a JSON file.
is something like this:
import import jsson bs4 import beautiful soup def main (): data = [] filename in glob.iglob ('* .html' ): F (s) as the open (filename): soup = beautiful soup (f) title = soup.find ("span", id = "btAsinTitle") data.appen D ({"title": title.get_text () , "Author": title.find_next ("a", href = true) .get_text (), "isbn": soup.find ('b', text = 'isben-10:'). Next_sibling, "weight": soup.fund ('b', text = 'shipping weight:'). Next-normal, "price": outf: json.dump as open ("my_output.json", "w") as soup.fank all ('span', {"class": 'bb_price'})}) (Data, outf) main ()
Comments
Post a Comment