Ronique Hossain Ronique Hossain - 1 year ago 212
Python Question

Parsing a JSON file with BeautifulSoup

Fairly new to coding so bear with me for any fundamental mistakes. Simplified, I have this:

url = ""

lm_json = requests.get(url).json()

How would I go about parsing
with BeautifulSoup? I keep getting errors to open it as a file. I need to use BeautifulSoup because I'm using the result in a while loop.

From this step, I'd need to append it to the main soup.

Thanks for any help!

Answer Source

The HTML content is wrapped in a JSON. For your example, you can try:

url = ""
lm_json = requests.get(url).json()
soup = BeautifulSoup(lm_json["content_html"])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download