Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- reddit = praw.Reddit(client_id='S-_XsEaogVkpcw',
- client_secret='evu9J1Uw_P-q4g4Xh8lmmq1fqJg',
- user_agent='wedotests',
- username='Thisisfortestgoaway',
- password='fucksmileyface')
- def scrapePost(postUrl, urlArr, botArr):
- result = set()
- post = reddit.submission(url=postUrl)
- post.comments.replace_more(limit=0)
- for comment in post.comments.list():
- for word in urlArr:
- index = comment.body.find(word)
- tmp = comment.body
- while index != -1:
- subComment = tmp[:index]
- startIndex = 0
- endIndex = 0
- if subComment.rfind(' ') >= subComment.rfind('/'):
- startIndex = subComment.rfind(' ')
- else:
- startIndex = subComment.rfind('/')
- startIndex += 1
- subComment = tmp[startIndex:]
- if subComment.find(')') <= subComment.find(' '):
- endIndex = subComment.find(')')
- else:
- endIndex = subComment.find(' ')
- endIndex += startIndex
- if endIndex == startIndex-1:
- endIndex = len(tmp)
- result.add(tmp[startIndex:endIndex])
- tmp = tmp[endIndex:]
- index = tmp.find(word)
- for word in botArr:
- tmp = comment.body.lower()
- index = tmp.find(word)
- while index != -1:
- subComment = tmp[index:]
- endIndex = subComment.find(')')
- endIndex += index+1
- result.add(tmp[index:endIndex])
- tmp = tmp[endIndex:]
- index = tmp.find(word)
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement