Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import logging
- import time
- import traceback
- import pandas as pd
- from src.services.utils.logger import LOGGER
- log = logging.getLogger(LOGGER)
- class CSVRoboHustlerByUrl:
- def __init__(self, robo_hustler_service, csv_service):
- self.robo_hustler_service = robo_hustler_service
- self.csv_service = csv_service
- def robo_hustler_loop(self, tags_csv_file_path):
- df = pd.read_csv(tags_csv_file_path, error_bad_lines=False)
- urls = df.iloc[:, 0] # selects first column
- #I assume that you want to like a few posts and have a correct input file, a csv with 1 column with urls for example
- for url in urls:
- start_time_iter = time.time()
- try:
- self.robo_hustler_service.like_post(url)
- except Exception as e:
- tb = traceback.format_exc()
- log.error("Exception: like_post failed for {} with {}\n{}".format(url, e, tb))
- scraped_hashtag_info_per_tag = None
- elapsed_time = time.time() - start_time_iter
- log.info("Liking posts done for{} "
- .format(elapsed_time))
- #Almost the same code with for all the other robo_hustler methods with correct input parameters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement