Advertisement
Guest User

Untitled

a guest
Jul 7th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. import praw
  2.  
  3. reddit = praw.Reddit(client_id='S-_XsEaogVkpcw',
  4. client_secret='evu9J1Uw_P-q4g4Xh8lmmq1fqJg',
  5. user_agent='wedotests',
  6. username='Thisisfortestgoaway',
  7. password='fucksmileyface')
  8.  
  9. def scrapePost(postUrl, urlArr, botArr):
  10. result = set()
  11. post = reddit.submission(url=postUrl)
  12. post.comments.replace_more(limit=0)
  13. for comment in post.comments.list():
  14. for word in urlArr:
  15. index = comment.body.find(word)
  16. tmp = comment.body
  17.  
  18. while index != -1:
  19. subComment = tmp[:index]
  20. startIndex = 0
  21. endIndex = 0
  22. if subComment.rfind(' ') >= subComment.rfind('/'):
  23. startIndex = subComment.rfind(' ')
  24. else:
  25. startIndex = subComment.rfind('/')
  26. startIndex += 1
  27. subComment = tmp[startIndex:]
  28. if subComment.find(')') <= subComment.find(' '):
  29. endIndex = subComment.find(')')
  30. else:
  31. endIndex = subComment.find(' ')
  32.  
  33. endIndex += startIndex
  34. if endIndex == startIndex-1:
  35. endIndex = len(tmp)
  36. result.add(tmp[startIndex:endIndex])
  37. tmp = tmp[endIndex:]
  38. index = tmp.find(word)
  39.  
  40. for word in botArr:
  41. tmp = comment.body.lower()
  42. index = tmp.find(word)
  43.  
  44. while index != -1:
  45.  
  46. subComment = tmp[index:]
  47. endIndex = subComment.find(')')
  48. endIndex += index+1
  49.  
  50. result.add(tmp[index:endIndex])
  51. tmp = tmp[endIndex:]
  52. index = tmp.find(word)
  53. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement