Created
February 24, 2019 07:17
-
-
Save DanNi0130/7dc0e17c83bc91e704ed97fd432ed7f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def scrapethread(cleanthread): # We need to feed the thread data into the function | |
singlethreadlinksearch = re.compile(r'\<a class="storylink" href="(.+?)"\>') | |
singlethreadlink = singlethreadlinksearch.findall(str(cleanthread)) | |
commenterIDsearch = re.compile(r'user\?id=(.+?)"') | |
commenterIDs = commenterIDsearch.findall(str(cleanthread)) | |
try: | |
firstcommenter = commenterIDs[1] # If there are no commenters this will fail, so we wrap it in a try/except just in case | |
except: | |
firstcommenter = "No commenters" | |
return singlethreadlink, firstcommenter # Return the variables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment