Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions emailphonescraping.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
import re
from urllib.request import urlopen

f = urlopen('http://www.bc.edu/a-z/directories/contact/quicknos.html')
f = urlopen('http://www.bc.edu/a-z/directories/contact/quicknos.html') #target site

s = BeautifulSoup(f, 'html.parser')
s = s.get_text()

phone = re.findall(r"((?:\d{3}|\(\d{3}\))?(?:\s|-|\.)?\d{3}(?:\s|-|\.)\d{4})",s)
phone = re.findall(r"((?:\d{3}|\(\d{3}\))?(?:\s|-|\.)?\d{3}(?:\s|-|\.)\d{4})",s) #searching characters
emails = re.findall(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,3}",s)

if len(phone) == 0:
print ("Sorry, no phone number found.")
print ("Sorry, no phone number found.") #Checking phone no. availability and Number of contacts found.

print('------------')
print ()
Expand All @@ -34,7 +34,8 @@
print()

if len(emails) == 0:
print("Sorry, no email address found.")
print("Sorry, no email address found.") #Checking email address availablity and Number of email addresses found

print('------------')
print()
else:
Expand Down