Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
webdesigner
Picture by Okinawa Soba
WHAT is REGEX Regular Expressions A special text string that describes a search pattern
EXAMPLES Find email address (?:[a-z0-9!#$%&*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&*+/=?^_` {|}~-]+)*|"(?:[x01-x08x0bx0cx0e-x1fx21x...
EXAMPLES Find email address easier w[w._]+@[w.]+[.]w+{2,4}
EXAMPLES Find email address easier “My email address is: stelian@firez.be” w[w._]+@[w.]+[.]w+{2,4} “My email address is: s...
EXAMPLES Find email address easier “My email address is: stelian@firez.be” w[w._]+@[w.]+[.]w+{2,4} “My email address is: s...
WHAT is PYTHON  Life is short, use Python
WHO uses PYTHON Google Blender 3D Civilization 4
WHY PYTHON Lots of modules Easy to read syntax API wrappers Great community
PYTHON does     click picture to open video
SEARCH TWITTERAPI limitations    150 anonymous calls per hour    350 authenticated calls per hour    results from only the...
SEARCH TWITTERRequirements   minimum Python knowledge   Twitter API wrapper (twython)
EXAMPLES Designers in Antwerpen  1 from twython import Twython  2 twitter = Twython()  3 search_results = twitter.searchTw...
EXAMPLES Designers in Antwerpen 1 from twython import Twython 2 twitter = Twython() 3 user_info = twitter.getUserTimeline(...
http://regular-expressions.infoSams Teach Yourself Regular Expressions in 10 Minutes           Python v2.6.6 documentation...
Upcoming SlideShare
Loading in …5
×

Regex, Python & Twitter

2,573 views

Published on

Using regular expressions and python to search twitter like a boss

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Regex, Python & Twitter

  1. 1. webdesigner
  2. 2. Picture by Okinawa Soba
  3. 3. WHAT is REGEX Regular Expressions A special text string that describes a search pattern
  4. 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
  5. 5. EXAMPLES Find email address easier w[w._]+@[w.]+[.]w+{2,4}
  6. 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. 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”
  8. 8. WHAT is PYTHON Life is short, use Python
  9. 9. WHO uses PYTHON Google Blender 3D Civilization 4
  10. 10. WHY PYTHON Lots of modules Easy to read syntax API wrappers Great community
  11. 11. PYTHON does click picture to open video
  12. 12. SEARCH TWITTERAPI limitations 150 anonymous calls per hour 350 authenticated calls per hour results from only the past 7 days max 1500 results
  13. 13. SEARCH TWITTERRequirements minimum Python knowledge Twitter API wrapper (twython)
  14. 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. 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]
  16. 16. http://regular-expressions.infoSams Teach Yourself Regular Expressions in 10 Minutes Python v2.6.6 documentation Twython - Python wrapper for the Twitter API Twitter Search API

×