SlideShare a Scribd company logo
1 of 16
Download to read offline
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-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
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: 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”
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”
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 TWITTER
API limitations

    150 anonymous calls per hour
    350 authenticated calls per hour
    results from only the past 7 days
    max 1500 results
SEARCH TWITTER
Requirements

   minimum Python knowledge
   Twitter API wrapper (twython)
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’]
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']
http://regular-expressions.info
Sams Teach Yourself Regular Expressions in 10 Minutes


           Python v2.6.6 documentation
    Twython - Python wrapper for the Twitter API


                 Twitter Search API

More Related Content

What's hot

What's hot (20)

Interact with information on largest 100 btc accounts ( python skeleton code)
Interact with information on largest 100 btc accounts ( python skeleton code)Interact with information on largest 100 btc accounts ( python skeleton code)
Interact with information on largest 100 btc accounts ( python skeleton code)
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
 
C questions
C questionsC questions
C questions
 
Assignement c++
Assignement c++Assignement c++
Assignement c++
 
10 3 다중 배열
10 3 다중 배열10 3 다중 배열
10 3 다중 배열
 
4.6 deduction and induction
4.6 deduction and induction4.6 deduction and induction
4.6 deduction and induction
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
Arrays
ArraysArrays
Arrays
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
Scala kansai summit-2016
Scala kansai summit-2016Scala kansai summit-2016
Scala kansai summit-2016
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
 
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solutionLet us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
Let us c (5th and 12th edition by YASHVANT KANETKAR) chapter 2 solution
 
Implementing string
Implementing stringImplementing string
Implementing string
 
Insertion Sort Code
Insertion Sort CodeInsertion Sort Code
Insertion Sort Code
 
Basic program in java
Basic program in java Basic program in java
Basic program in java
 
Seg code
Seg codeSeg code
Seg code
 
Om (Cont.)
Om (Cont.)Om (Cont.)
Om (Cont.)
 
C- Programs - Harsh
C- Programs - HarshC- Programs - Harsh
C- Programs - Harsh
 
The Ring programming language version 1.3 book - Part 32 of 88
The Ring programming language version 1.3 book - Part 32 of 88The Ring programming language version 1.3 book - Part 32 of 88
The Ring programming language version 1.3 book - Part 32 of 88
 
Fs2 - Crash Course
Fs2 - Crash CourseFs2 - Crash Course
Fs2 - Crash Course
 

Similar to Regex, Python & Twitter

Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
aztack
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
oscon2007
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
Lei Kang
 

Similar to Regex, Python & Twitter (20)

C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
Writing DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby ConfWriting DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby Conf
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184
 
Unsung Heroes of PHP
Unsung Heroes of PHPUnsung Heroes of PHP
Unsung Heroes of PHP
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
The Ring programming language version 1.10 book - Part 50 of 212
The Ring programming language version 1.10 book - Part 50 of 212The Ring programming language version 1.10 book - Part 50 of 212
The Ring programming language version 1.10 book - Part 50 of 212
 
Malli: inside data-driven schemas
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemas
 
WTF Oriented Programming, com Fabio Akita
WTF Oriented Programming, com Fabio AkitaWTF Oriented Programming, com Fabio Akita
WTF Oriented Programming, com Fabio Akita
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
 
The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010
 
Grokking regex
Grokking regexGrokking regex
Grokking regex
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
 
Swift Sequences & Collections
Swift Sequences & CollectionsSwift Sequences & Collections
Swift Sequences & Collections
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

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
  • 5. EXAMPLES Find email address easier w[w._]+@[w.]+[.]w+{2,4}
  • 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”
  • 8. WHAT is PYTHON Life is short, use Python
  • 9. WHO uses PYTHON Google Blender 3D Civilization 4
  • 10. WHY PYTHON Lots of modules Easy to read syntax API wrappers Great community
  • 11. PYTHON does click picture to open video
  • 12. SEARCH TWITTER API limitations 150 anonymous calls per hour 350 authenticated calls per hour results from only the past 7 days max 1500 results
  • 13. SEARCH TWITTER Requirements minimum Python knowledge Twitter API wrapper (twython)
  • 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']
  • 16. http://regular-expressions.info Sams Teach Yourself Regular Expressions in 10 Minutes Python v2.6.6 documentation Twython - Python wrapper for the Twitter API Twitter Search API

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n