BP2024/harvester/main.py
2024-04-09 15:39:11 +02:00

30 lines
921 B
Python

import argparse
from Facebook.facebook_crawler import FacebookCrawler
from Reddit.reddit_crawler import RedditCrawler
FACEBOOK_URL = 'https://www.facebook.com/'
REDDIT_URL = 'https://www.reddit.com/'
if __name__ == '__main__':
# parsing arguments
parser = argparse.ArgumentParser(description = "Facebook scraper")
parser.add_argument("file_name", help = 'Name of the .txt file with URLS')
args = parser.parse_args()
user_input = input('Hello, do you want to scraper Facebook or reddit? [F/r]: ')
while user_input.upper() not in ['F', 'R']:
user_input = input('Do you want to scrape Facebook or reddit? [F/r]: ')
if user_input == 'F':
facebook = FacebookCrawler(FACEBOOK_URL, args.file_name)
facebook.allow_cookies()
facebook.login()
facebook.crawl()
else:
reddit = RedditCrawler(REDDIT_URL, args.file_name)
print(reddit)