Esempio n. 1
0
 def get_elements(self):
     for re in reddit.user_posts(
             username=self.data['user'],
             find_submissions=self.data['scan_submissions'],
             find_comments=self.data['scan_comments']):
         if self.check_filters(re):
             yield re
Esempio n. 2
0
	def get_elements(self):
		check_last = self.data['check_last_seen_posts']
		if not check_last or check_last < 1:
			check_last = None
			last_seen = None
		else:
			last_seen = get_last_seen_posts(self.data['user'], check_last, self.data['check_last_seen_utc'])
		
		last_seen_i = None
		for re in reddit.user_posts(
				username=self.data['user'],
				find_submissions=self.data['scan_submissions'],
				find_comments=self.data['scan_comments'],
				find_limit=self.data['scan_limit'],
				deep_find_submissions=self.data['deep_scan_submissions'],
				deep_find_comments=self.data['deep_scan_comments']):
			if check_last is not None:
				res = self.is_new_post(re, last_seen)
				if type(res) is int:
					if last_seen_i is None:
						print("Reached start of last seen posts at: (%s/%s) [%s] %s %s"%(res, len(last_seen), re.strf_created_utc(), re.author, re.id), debug=True)
					last_seen_i = res
				elif res is False:
					print("Reached end of last seen posts at: (%s/%s) [%s] %s %s"%(last_seen_i, len(last_seen), re.strf_created_utc(), re.author, re.id), debug=True)
					break
			if self.check_filters(re):
				yield re
 def test_user_posts(self):
     """ Load test user posts """
     posts = [
         p for p in pw.user_posts('test_reddit_scraper',
                                  find_comments=True,
                                  find_submissions=True)
     ]
     for p in posts:
         self.assertEqual(p.author,
                          'test_reddit_scraper',
                          msg='Invalid Post author!')