1
0

Cookiejar is configurable
Some checks failed
Build container / Package-Python (push) Failing after 25s
Build container / Package-Container (push) Successful in 1m30s

This commit is contained in:
Jon Michael Aanes 2024-04-18 00:13:56 +02:00
parent 553f6fe7d4
commit fdb6e2d180
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 9 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import logging
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('fetchers', metavar='FETCHER', type=str, nargs='+')
parser.add_argument('--cookiejar', action = 'store_true')
return parser.parse_args()
def main():
@ -12,7 +13,7 @@ def main():
logging.getLogger('personal_data').setLevel('INFO')
args = parse_arguments()
scraper_filter = frozenset(args.fetchers)
personal_data.main.main(scraper_filter)
personal_data.main.main(scraper_filter, use_cookiejar = args.cookiejar)
if __name__ == '__main__':
main()

View File

@ -171,9 +171,13 @@ def send_notification(session: requests.Session, scraper_name: str, latest_dict:
body.append(f'{k}: {v}\n')
mailgun.send_email(session, f'Updated {scraper_name}', ''.join(body))
def main(scraper_filter: frozenset[str]):
cookiejar = browsercookie.firefox()
logger.info('Got cookiejar from firefox: %s cookies', len(cookiejar))
def main(scraper_filter: frozenset[str], use_cookiejar: bool):
if use_cookiejar:
cookiejar = browsercookie.firefox()
logger.info('Got cookiejar from firefox: %s cookies', len(cookiejar))
else:
cookiejar = []
logger.warning('No cookiejar is used')
for scraper_cls in personal_data.data.Scraper.__subclasses__():
session = get_session(cookiejar, with_cfscrape=scraper_cls.requires_cfscrape())