replace json.dumps with direct calls to JSONEncoder.encode

This commit is contained in:
Mike Fährmann
2023-02-09 15:50:55 +01:00
parent dd884b02ee
commit 5503ac4d5e
5 changed files with 19 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2019-2022 Mike Fährmann
# Copyright 2019-2023 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -9,7 +9,7 @@
"""Extractors for https://500px.com/"""
from .common import Extractor, Message
import json
from .. import util
BASE_PATTERN = r"(?:https?://)?(?:web\.)?500px\.com"
@@ -86,7 +86,7 @@ class _500pxExtractor(Extractor):
}
data = {
"operationName": opname,
"variables" : json.dumps(variables),
"variables" : util.json_dumps(variables),
"query" : QUERIES[opname],
}
return self.request(

View File

@@ -12,7 +12,6 @@ from .common import Extractor, Message
from .. import text, util, exception
from ..cache import cache
import itertools
import json
BASE_PATTERN = r"(?:https?://)?(?:\w+\.)?pinterest\.[\w.]+"
@@ -504,7 +503,10 @@ class PinterestAPI():
"username_or_email": username,
"password" : password,
}
data = {"data": json.dumps({"options": options}), "source_url": ""}
data = {
"data" : util.json_dumps({"options": options}),
"source_url": "",
}
try:
response = self.extractor.request(
@@ -523,7 +525,10 @@ class PinterestAPI():
def _call(self, resource, options):
url = "{}/resource/{}Resource/get/".format(self.root, resource)
params = {"data": json.dumps({"options": options}), "source_url": ""}
params = {
"data" : util.json_dumps({"options": options}),
"source_url": "",
}
response = self.extractor.request(
url, params=params, headers=self.headers,