Answer the question
In order to leave comments, you need to log in
Why is JSON.loads throwing an error?
The variable contains both HTML tags and JavaScript data. It is necessary to place in the Python dictionary a part of the parsed page that looks like: "key" : "value".
This script is throwing an error for some reason.
TypeError: the JSON object must be str, bytes or bytearray, not BeautifulSoup
import requests # модуль для парсинга
from bs4 import BeautifulSoup #модуль для парсинга
import json
s = requests.Session()
loging = s.get(URL, headers=HEADERS, params=None)
soup = BeautifulSoup(loging.content, 'html.parser')
json_dat = json.loads(soup)
Answer the question
In order to leave comments, you need to log in
Here you make an html parser object:
soup = BeautifulSoup(loging.content, 'html.parser')
json_dat = json.loads(soup)
TypeError: the JSON object must be str, bytes or bytearray, not BeautifulSoup
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question