Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1.  
  2. import logging
  3. import time
  4. import traceback
  5.  
  6. import pandas as pd
  7. from src.services.utils.logger import LOGGER
  8.  
  9. log = logging.getLogger(LOGGER)
  10.  
  11. class CSVRoboHustlerByUrl:
  12. def __init__(self, robo_hustler_service, csv_service):
  13. self.robo_hustler_service = robo_hustler_service
  14. self.csv_service = csv_service
  15.  
  16. def robo_hustler_loop(self, tags_csv_file_path):
  17. df = pd.read_csv(tags_csv_file_path, error_bad_lines=False)
  18. urls = df.iloc[:, 0] # selects first column
  19. #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
  20.  
  21. for url in urls:
  22. start_time_iter = time.time()
  23.  
  24. try:
  25. self.robo_hustler_service.like_post(url)
  26. except Exception as e:
  27. tb = traceback.format_exc()
  28. log.error("Exception: like_post failed for {} with {}\n{}".format(url, e, tb))
  29. scraped_hashtag_info_per_tag = None
  30.  
  31. elapsed_time = time.time() - start_time_iter
  32. log.info("Liking posts done for{} "
  33. .format(elapsed_time))
  34.  
  35. #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