Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
@edsu edsu small tweaks e7a56e9 Oct 28, 2019
3 contributors

Users who have contributed to this file

@edsu @pbinkley @hugovk
executable file 19 lines (16 sloc) 461 Bytes
#!/usr/bin/env python3
"""
Print out the URLs in a tweet json stream.
"""
from __future__ import print_function
import json
import fileinput
for line in fileinput.input():
tweet = json.loads(line)
for url in tweet["entities"]["urls"]:
if 'unshortened_url' in url:
print(url['unshortened_url'])
elif url.get('expanded_url'):
print(url['expanded_url'])
elif url.get('url'):
print(url['url'])
You can’t perform that action at this time.