-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaddress_module.py
More file actions
76 lines (59 loc) · 2.74 KB
/
address_module.py
File metadata and controls
76 lines (59 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from clear_module import clear_screen
class StreetAddress: # Initialize object
def __init__(self):
self.street = ""
self.zip = ""
self.state = ""
self.city = ""
def update_info(self): # Method to assign values to attributes of the StreetAddress class
clear_screen()
self.street = input("Street: ")
self.zip = input("ZIP Code: ")
self.state = input("State: ")
self.city = input("City: ")
def display_info(self): # Method to display values of the attributes of the StreetAddress class
clear_screen()
info = f"Street: {self.street}\n"\
f"ZIP Code: {self.zip}\n"\
f"State: {self.state}\n"\
f"City: {self.city}\n\n"
print(info)
# Everything past this point is URL generation -->
def generate_truepeoplesearch_url(self):
if self.street and ((self.city and self.state) or self.zip):
address_parts = [self.street.replace(" ", "%20")]
location_parts = []
if self.city:
location_parts.append(self.city)
location_parts.append(self.state)
if self.zip:
location_parts.append(self.zip)
location_url = "%20".join(location_parts) if location_parts else ""
location_url = location_url.replace(" ", "%20")
return f"https://www.truepeoplesearch.com/resultaddress?streetaddress={address_parts[0]}&citystatezip={location_url}"
return "No valid address components to generate a URL."
def generate_thatsthem_url(self):
if self.street and ((self.city and self.state) or self.zip):
address_parts = [self.street.replace(" ", "-")]
location_parts = []
if self.city:
location_parts.append(self.city.replace(" ", "-"))
location_parts.append(self.state)
if self.zip:
location_parts.append(self.zip)
location_url = "-".join(location_parts) if location_parts else ""
location_url = location_url.replace(" ", "-")
return f"https://thatsthem.com/address/{address_parts[0]}-{location_url}"
return "No valid address components to generate a URL."
def generate_zillow_url(self):
if self.street:
address_parts = [self.street.replace(" ", "-")]
if self.city:
address_parts.append(self.city.replace(" ", "-"))
if self.state:
address_parts.append(self.state)
if self.zip:
address_parts.append(self.zip)
url = "https://www.zillow.com/homes/" + "-".join(address_parts)
return url
return "No valid address components to generate a URL."