On ajoute un outil de tracking pour comprendre les erreurs FB
This commit is contained in:
parent
2ace02a5b7
commit
70755b8f5e
@ -69,15 +69,19 @@ class CExtractor(TwoStepsExtractor):
|
|||||||
raise Exception(_("the page was not yet populated with events, so the loading time was probably too short"))
|
raise Exception(_("the page was not yet populated with events, so the loading time was probably too short"))
|
||||||
|
|
||||||
if not self.found and debug:
|
if not self.found and debug:
|
||||||
directory = "errors/"
|
|
||||||
if not os.path.exists(directory):
|
|
||||||
os.makedirs(directory)
|
|
||||||
now = datetime.now()
|
|
||||||
filename = directory + now.strftime("%Y%m%d_%H%M%S") + ".html"
|
|
||||||
logger.warning("cannot find any event link in events page. Save content page in " + filename)
|
logger.warning("cannot find any event link in events page. Save content page in " + filename)
|
||||||
with open(filename, "w") as text_file:
|
self.dump_content_for_debug(content)
|
||||||
text_file.write("<!-- " + self.url + " -->\n\n")
|
|
||||||
text_file.write(content)
|
|
||||||
|
def dump_content_for_debug(self, content):
|
||||||
|
directory = "errors/"
|
||||||
|
if not os.path.exists(directory):
|
||||||
|
os.makedirs(directory)
|
||||||
|
now = datetime.now()
|
||||||
|
filename = directory + now.strftime("%Y%m%d_%H%M%S") + ".html"
|
||||||
|
with open(filename, "w") as text_file:
|
||||||
|
text_file.write("<!-- " + self.url + " -->\n\n")
|
||||||
|
text_file.write(content)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +94,8 @@ class CExtractor(TwoStepsExtractor):
|
|||||||
default_values=None,
|
default_values=None,
|
||||||
published=False,
|
published=False,
|
||||||
):
|
):
|
||||||
|
debug = True
|
||||||
|
|
||||||
fevent = None
|
fevent = None
|
||||||
soup = BeautifulSoup(event_content, "html.parser")
|
soup = BeautifulSoup(event_content, "html.parser")
|
||||||
for json_script in soup.find_all("script", type="application/json"):
|
for json_script in soup.find_all("script", type="application/json"):
|
||||||
@ -106,6 +111,7 @@ class CExtractor(TwoStepsExtractor):
|
|||||||
|
|
||||||
self.add_event(default_values, **event)
|
self.add_event(default_values, **event)
|
||||||
else:
|
else:
|
||||||
|
self.dump_content_for_debug(event_content)
|
||||||
raise Exception(
|
raise Exception(
|
||||||
_("Cannot get Facebook event from {}").format(event_url)
|
_("Cannot get Facebook event from {}").format(event_url)
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user