Skip to content

Instantly share code, notes, and snippets.

@nickedes
Last active August 29, 2015 14:07
Show Gist options
  • Save nickedes/aeb1590e99de40fa136a to your computer and use it in GitHub Desktop.
Save nickedes/aeb1590e99de40fa136a to your computer and use it in GitHub Desktop.
extract links from a chat
import json
from pprint import pprint
import re
with open('complete.pretty.json') as data_file:
data = json.load(data_file)
for i in range(0, len(data)):
url = data[i]['body']
if (re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', url) ):
print data[i]['author']
print re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment