Ronique Hossain Ronique Hossain - 8 months ago 51
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!


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"])