More Related Content
Similar to Regex, Python & Twitter (20)
Regex, Python & Twitter
- 3. WHAT is REGEX
Regular Expressions
A special text string that
describes a search pattern
- 4. EXAMPLES
Find email address
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`
{|}~-]+)*|"(?:[x01-x08x0bx0cx0e-x1fx21x23-x5b
x5d-x7f]|[x01-x09x0bx0cx0e-x7f])*")@(?:(?:[a-
z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-
z0-9])?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).)
{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-
z0-9]:(?:[x01-x08x0bx0cx0e-x1fx21-x5ax53-x7f]|
[x01-x09x0bx0cx0e-x7f])+)])
✔ The Official Standard: RFC 2822
- 6. EXAMPLES
Find email address easier
“My email address is: stelian@firez.be”
w[w._]+@[w.]+[.]w+{2,4}
“My email address is: stelian@firez.be”
w[w._]+@[w.]+[.]w+{2,4}
“My email address is: stelian@firez.be”
w[w._]+@[w.]+[.]w+{2,4}
“My email address is: stelian@firez.be”
- 7. EXAMPLES
Find email address easier
“My email address is: stelian@firez.be”
w[w._]+@[w.]+[.]w+{2,4}
“My email address is: stelian@firez.be”
w[w._]+@[w.]+[.]w+{2,4}
“My email address is: stelian@firez.be”
w[w._]+@[w.]+[.]w+{2,4}
“My email address is: stelian@firez.be”
- 10. WHY PYTHON
Lots of modules
Easy to read syntax
API wrappers
Great community
- 14. EXAMPLES
Designers in Antwerpen
1 from twython import Twython
2 twitter = Twython()
3 search_results = twitter.searchTwitter(q="design",
since_id=0, rpp='100', geocode="51.21992,4.39625,10km",
page=1)
4
5 for tweet in search_results['results']):
6 print tweet[‘id’]
7 print tweet[‘created_at’]
8 print tweet[‘from_user’]
9 print tweet[‘profile_image_url’]
10 print tweet[‘text’]
- 15. EXAMPLES
Designers in Antwerpen
1 from twython import Twython
2 twitter = Twython()
3 user_info = twitter.getUserTimeline(id=tweet['from_user'])
[0]['user']
4 print user_info['name']
5 print user_info['time_zone']
6 print user_info['location']
7 print user_info['description']
8 print user_info['url']
Editor's Notes
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n