[bcy] fix JSONDecodeError (#3321)

pull/3353/head
Mike Fährmann 2 years ago
parent 5b9a22af7f
commit 86a396e086
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -96,11 +96,13 @@ class BcyExtractor(Extractor):
def _data_from_post(self, post_id):
url = "{}/item/detail/{}".format(self.root, post_id)
page = self.request(url, notfound="post").text
return json.loads(
text.extr(page, 'JSON.parse("', '");')
data = (text.extr(page, 'JSON.parse("', '");')
.replace('\\\\u002F', '/')
.replace('\\"', '"')
)["detail"]
.replace('\\"', '"'))
try:
return json.loads(data)["detail"]
except ValueError:
return json.loads(data.replace('\\"', '"'))["detail"]
class BcyUserExtractor(BcyExtractor):
@ -187,6 +189,10 @@ class BcyPostExtractor(BcyExtractor):
("https://bcy.net/item/detail/6747523535150783495", {
"count": 0,
}),
# JSON decode error (#3321)
("https://bcy.net/item/detail/7166939271872388110", {
"count": 0,
}),
)
def posts(self):

Loading…
Cancel
Save