Created
September 1, 2018 15:21
-
-
Save santosh/521ec3c53f60d03879fd71eadffe37af to your computer and use it in GitHub Desktop.
regex fun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| # print(re.split(r'(s*)', 'here are some words')) | |
| # print(re.split(r'[a-f]', 'kjfsldhjakcnv', re.I | re.M)) | |
| print(re.findall(r'\d', 'ocinwe324 main st.asdvce')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re, urllib | |
| try: | |
| import urllib.request | |
| except ModuleNotFoundError: | |
| pass | |
| sites = 'google yahoo cnn msn'.split() | |
| for s in sites: | |
| print("Searching:", s) | |
| try: | |
| u = urllib.urlopen('https://' + s + '.com') | |
| except: | |
| u = urllib.request.urlopen('https://' + s + '.com') | |
| text= u.read() | |
| title = re.findall(r'<title>+.*</title>', str(text), re.I|re.M) | |
| print(title[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Implement multithreading in regex02.py to simultaneously search all the website altogether.