mirror of
https://github.com/bellingcat/reddit-post-scraping-tool.git
synced 2026-06-11 21:18:29 +03:00
Update and rename main.py to __main.py
Refactored and added doc strings to code.
This commit is contained in:
@@ -1,13 +0,0 @@
|
|||||||
from reddit_post_scraping_tool.reddit_post_scraping_tool import *
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
try:
|
|
||||||
check_updates("1.3.0.1")
|
|
||||||
reddit_post_scraper()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
log.warning(f"User interruption detected.")
|
|
||||||
except Exception as e:
|
|
||||||
log.error(e)
|
|
||||||
finally:
|
|
||||||
log.info(f'Finished in {datetime.now() - start_time} seconds.')
|
|
||||||
30
rpst/__main.py
Normal file
30
rpst/__main.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from rpst.__rpst import log, start_scraper, check_updates, create_parser
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
"""
|
||||||
|
Main entry point for the program. It creates a parser, parses the command line arguments,
|
||||||
|
checks for updates, starts the scraper, and handles any exceptions that occur during the execution.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Create a parser and parse the command line arguments
|
||||||
|
parser = create_parser()
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Record the start time
|
||||||
|
start_time = datetime.now()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Check for updates
|
||||||
|
check_updates(version_tag="1.4.0.0")
|
||||||
|
|
||||||
|
# Start the scraper with the parsed arguments
|
||||||
|
start_scraper(keyword=args.keyword, subreddit=args.subreddit,
|
||||||
|
listing=args.listing, timeframe=args.timeframe, limit=args.limit)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
log.warning("User interruption detected.")
|
||||||
|
except Exception as e:
|
||||||
|
log.error(f"An error occurred: {e}")
|
||||||
|
finally:
|
||||||
|
log.info(f'Finished in {datetime.now() - start_time} seconds.')
|
||||||
Reference in New Issue
Block a user