Guest User

Generic Stream Parser

a guest
Mar 9th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. from time import time
  2. import praw
  3.  
  4. START = time()
  5. reddit = praw.Reddit(
  6.     password='______',
  7.     username='______',
  8.     client_id='______',
  9.     client_secret='______',
  10.     user_agent='script:pentest.bot.script:v0.0.1:/u/______',
  11. )
  12.  
  13. """
  14. from pprint import pprint
  15. pprint(dir(submission))
  16.  
  17. ['approved_by',
  18. 'archived',
  19. 'author',
  20. 'author_flair_css_class',
  21. 'author_flair_text',
  22. 'banned_by',
  23. 'clear_vote',
  24. 'clicked',
  25. 'comment_limit',
  26. 'comment_sort',
  27. 'comments',
  28. 'contest_mode',
  29. 'created',
  30. 'created_utc',
  31. 'delete',
  32. 'distinguished',
  33. 'domain',
  34. 'downs',
  35. 'downvote',
  36. 'duplicates',
  37. 'edit',
  38. 'edited',
  39. 'flair',
  40. 'fullname',
  41. 'gild',
  42. 'gilded',
  43. 'hidden',
  44. 'hide',
  45. 'hide_score',
  46. 'id',
  47. 'id_from_url',
  48. 'is_self',
  49. 'likes',
  50. 'link_flair_css_class',
  51. 'link_flair_text',
  52. 'locked',
  53. 'media',
  54. 'media_embed',
  55. 'mod',
  56. 'mod_reports',
  57. 'name',
  58. 'num_comments',
  59. 'num_reports',
  60. 'over_18',
  61. 'parse',
  62. 'permalink',
  63. 'post_hint',
  64. 'preview',
  65. 'quarantine',
  66. 'removal_reason',
  67. 'reply',
  68. 'report',
  69. 'report_reasons',
  70. 'save',
  71. 'saved',
  72. 'score',
  73. 'secure_media',
  74. 'secure_media_embed',
  75. 'selftext',
  76. 'selftext_html',
  77. 'shortlink',
  78. 'spoiler',
  79. 'stickied',
  80. 'subreddit',
  81. 'subreddit_id',
  82. 'suggested_sort',
  83. 'thumbnail',
  84. 'title',
  85. 'unhide',
  86. 'unsave',
  87. 'ups',
  88. 'upvote',
  89. 'url',
  90. 'user_reports',
  91. 'visited']
  92. """
  93.  
  94.  
  95. def handle(submission):
  96.     """
  97.    Disposition the content however you need.
  98.    See comment block above for available methods
  99.    and attributes on the submission object
  100.  
  101.    Example:
  102.  
  103.    print(submission.author.name)
  104.  
  105.    :param submission: PRAW submission object
  106.    :return: None
  107.    """
  108.     pass
  109.  
  110.  
  111. def main():
  112.     for submission in reddit.subreddit('openpentesting').stream.submissions():
  113.         if submission.created_utc < START:
  114.             continue
  115.         handle(submission)
  116.  
  117.  
  118. if __name__ == '__main__':
  119.     main()
Add Comment
Please, Sign In to add comment