I have multiple web scraping projects (python + scrapy)
I have a common helper file, that I include in all of these projects, the helper file is something like this:
helper.py
def has_any_numbers(input_str):
if input_str:
return any(char.isdigit() for char in input_str)
else:
return False
def read_env_config(spider):
config = AutoConfig(search_path='../.env')
# output file specifics
spider.region_name = config('REGION_NAME')
spider.aws_access_key_id = config('AWS_ACCESS_KEY_ID')
spider.aws_secret_access_key = config('AWS_SECRET_ACCESS_KEY')
spider.bucket_name = config('BUCKET_NAME')
There are some common config, such as the s3 output path and credentials that I am reading in the helper file... spider is the main class that I pass into this helper function... not sure if it would be possible to share a static class which has all the config values?
At the moment, I am copying this helper file in every project, is there a way to share this file among multiple project?