Grab data from Twitter and parse
<p>I am trying to:</p>

<p>Grab multiple tweets, find urls inside the tweets, grab the urls I found and save each "url data" to different txt file.</p>

<p>So far I managed to write these parts and I am stuck, can someone please help me?</p>

<p>Grab tweets:</p>

<pre><code>import tweepy
from tweepy import OAuthHandler
import sys
import re

def process_or_store(tweet):
    print(json.dumps(tweet))

consumer_key = '***************************'
consumer_secret = '******************************'
access_token = '*******************************'
access_secret = '****************************'
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)

f = open("C:\\Twitter\Twitts.txt",'w')
print &gt;&gt;f, 'twits'


for status in tweepy.Cursor(api.home_timeline).items(20):
    # Process a single status
    print(status.text)
    f.write(status.text+ '\n')


def extract_urls(fname):
    with open(fname) as f:
        return re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&amp;+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', f.read())
</code></pre>

<p>Data from URL:</p>

<pre><code>import urllib2

url = 'https://***************'
response = urllib2.urlopen(url)
with open('C:\\Twitter\Data_from_urls\ + "url"', 'w') as f:
    f.write(response.read())
</code></pre>