Skip to content

Instantly share code, notes, and snippets.

@santosh
Created September 1, 2018 15:21
Show Gist options
  • Save santosh/521ec3c53f60d03879fd71eadffe37af to your computer and use it in GitHub Desktop.
Save santosh/521ec3c53f60d03879fd71eadffe37af to your computer and use it in GitHub Desktop.
regex fun
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'))
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])
@santosh
Copy link
Author

santosh commented Sep 1, 2018

Implement multithreading in regex02.py to simultaneously search all the website altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment