Skip to content

Commit

Permalink
Log cookies information to std_err
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMulti0 committed Dec 11, 2021
1 parent 402c434 commit b895441
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/Scraper.Net.Facebook/get_page_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import sys
import traceback
import warnings
from datetime import datetime
from itertools import cycle
from random import shuffle
Expand Down Expand Up @@ -79,20 +80,20 @@ def set_cookie(cookies: List[str], initial=None):
if initial == cookie:
raise StopIteration

print(f'Trying cookies from file {cookie}')
warnings.warn(f'Trying cookies from file {cookie}')

try:
set_cookies(cookie)
except (InvalidCookies, FileNotFoundError) as e:
print(f'Failed to use cookies from file {cookie}:')
print(f'{type(e).__name__}: {e}')
warnings.warn(f'Failed to use cookies from file {cookie}:')
warnings.warn(f'{type(e).__name__}: {e}')

set_cookie(
cookies,
initial=cookie if initial is None else initial)

except StopIteration:
print("Not using cookies")
warnings.warn("Not using cookies")
return


Expand Down
9 changes: 5 additions & 4 deletions src/Scraper.Net.Facebook/get_posts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import sys
import traceback
import warnings
from datetime import datetime
from itertools import cycle
from random import shuffle
Expand Down Expand Up @@ -83,20 +84,20 @@ def set_cookie(cookies: List[str], initial=None):
if initial == cookie:
raise StopIteration

print(f'Trying cookies from file {cookie}')
warnings.warn(f'Trying cookies from file {cookie}')

try:
set_cookies(cookie)
except (InvalidCookies, FileNotFoundError) as e:
print(f'Failed to use cookies from file {cookie}:')
print(f'{type(e).__name__}: {e}')
warnings.warn(f'Failed to use cookies from file {cookie}:')
warnings.warn(f'{type(e).__name__}: {e}')

set_cookie(
cookies,
initial=cookie if initial is None else initial)

except StopIteration:
print("Not using cookies")
warnings.warn("Not using cookies")
return


Expand Down

0 comments on commit b895441

Please sign in to comment.