- reformat and refactor to pass tests
This commit is contained in:
@@ -250,16 +250,19 @@ class PatreonExtractor(Extractor):
|
|||||||
|
|
||||||
def _extract_bootstrap(self, page):
|
def _extract_bootstrap(self, page):
|
||||||
if "window.patreon.bootstrap," in page:
|
if "window.patreon.bootstrap," in page:
|
||||||
page_content = text.extr(page, "window.patreon.bootstrap,", "});")
|
content_begin = "window.patreon.bootstrap,"
|
||||||
json_string = page_content + "}"
|
content_end = "});"
|
||||||
|
json_string = text.extr(page, content_begin, content_end) + "}"
|
||||||
elif 'window.patreon = {"bootstrap":' in page:
|
elif 'window.patreon = {"bootstrap":' in page:
|
||||||
page_content = text.extr(page, 'window.patreon = {"bootstrap":', '},"apiServer"')
|
content_begin = 'window.patreon = {"bootstrap":'
|
||||||
json_string = page_content + "}"
|
content_end = '},"apiServer"'
|
||||||
|
json_string = text.extr(page, content_begin, content_end) + "}"
|
||||||
elif 'window.patreon = wrapInProxy({"bootstrap":' in page:
|
elif 'window.patreon = wrapInProxy({"bootstrap":' in page:
|
||||||
page_content = text.extr(page, 'window.patreon = wrapInProxy({"bootstrap":', '},"apiServer"')
|
content_begin = 'window.patreon = wrapInProxy({"bootstrap":'
|
||||||
json_string = page_content + "}"
|
content_end = '},"apiServer"'
|
||||||
|
json_string = text.extr(page, content_begin, content_end) + "}"
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Unknown HTML and JS structure. Page content is: {page}")
|
raise Exception("Unknown HTML and JS structure. Page:" + page)
|
||||||
return util.json_loads(json_string)
|
return util.json_loads(json_string)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user