def main(): parser = get_parser() args = parser.parse_args() if args.config is not None: load_config(filepath=args.config) scrapper = InstaScrapper(hide_browser=args.hide_browser) bot = InstaBot(scrapper, username=args.username, password=args.password) c = Controller(username=args.username) signal.signal(signal.SIGINT, partial(signal_handler, bot, c)) c.run(bot)
def setUp(self): config.load_config(filepath='test.config.yaml') self.scrapper = InstaScrapper(hide_browser=True) self.bot = InstaBot(self.scrapper, username=USERNAME, password=PASSWORD) self.hashtag = 'apartmentdecor' self.hashtag_dict = { 'hashtag': 'architecture', 'min_followers': 0, 'total_to_follow': 20 } self.users_to_unfollow = [ FollowedUser('juan', None), FollowedUser('miguel', None) ] self.hashtags = [self.hashtag, self.hashtag_dict]
post_link = bot.scrapper.generate_post_link_by_code(post_id) bot.scrapper.get_page(post_link) if bot.scrapper._is_liked: bot.unlike(post_link) bot.scrapper.get_page(post_link) def to_unlike(bot, post_id): post_link = bot.scrapper.generate_post_link_by_code(post_id) bot.scrapper.get_page(post_link) if not bot.scrapper._is_liked: bot.like(post_link) bot.scrapper.get_page(post_link) config.load_config(filepath='test.config.yaml') config.SAVE_SOURCE = True config.CONFIG['hide_browser'] = False s = InstaScrapper() bot = InstaBot(s) bot.start_browser() bot.login() bot.scrapper.get_page('/') bot.my_profile_info() bot.scrapper.user_info_in_post_page(bot.username) to_like(bot, NOT_FOLLOWED_USER['post_to_like_state']) to_unlike(bot, NOT_FOLLOWED_USER['post_to_unlike_state'])
def setUpClass(cls): load_config(filepath='test.config.yaml') mock_server_port = get_free_port() start_mock_server(mock_server_port) const.HOSTNAME = MOCK_HOSTNAME.format(port=mock_server_port)
def test_load_config(self): config.load_config(filepath='test.config.yaml') self.assertEqual(config.CONFIG['username'], 'discovrar') self.assertEqual(config.CONFIG['password'], 'discorvd') self.assertEqual(config.CONFIG['testing'], True)
def test_load_config_syntax_error_yaml(self): with self.assertRaises(SystemExit): config.load_config( filepath='tests/static/syntax.error.config.yaml')
def test_load_config_twice(self): config.load_config(filepath='test.config.yaml') result = config.load_config() self.assertIsNone(result)