Skip to content

Commit

Permalink
Improve content logging when there are no posts
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinzg committed Jun 16, 2020
1 parent 9086f0a commit 1a703c8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions facebook_scraper/page_iterators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import re
import textwrap
from typing import Iterator, Optional

from . import utils
Expand Down Expand Up @@ -66,8 +67,14 @@ def get_page(self) -> Page:
if not raw_posts:
logger.warning("No raw posts (<article> elements) were found in this page.")
if logger.isEnabledFor(logging.DEBUG):
content = utils.html2text(raw_page.html)
logger.debug("The page content is:\n---\n%s\n---\n", content)
content = textwrap.indent(
utils.html2text(raw_page.html),
prefix='| ',
predicate=lambda _: True,
)
sep = '+' + '-' * 60
logger.debug("The page url is: %s", self.response.url)
logger.debug("The page content is:\n%s\n%s%s\n", sep, content, sep)

return raw_posts

Expand Down

0 comments on commit 1a703c8

Please sign in to comment.