pyzill 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyzill/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ from pyzill.search import Search_all
2
+ from pyzill.search import Search_first_page
3
+ from pyzill.details import Get_from_property_url
4
+ from pyzill.details import Get_from_property_id
pyzill/details.py ADDED
@@ -0,0 +1,34 @@
1
+ import requests
2
+ import json
3
+ from pyzill.parse import parse_body_details_wrapper
4
+ def Get_from_property_url(property_url: str, proxy_url: str):
5
+ data = get_from_url(roomURL, proxy_url)
6
+ return data
7
+
8
+ def Get_from_property_id(property_id: int, proxy_url: str):
9
+ property_url = f"https://www.zillow.com/homedetails/any-title/{property_id}_zpid/"
10
+ data = get_from_url(property_url, proxy_url)
11
+ return data
12
+
13
+
14
+ def get_from_url(property_url: str, proxy_url: str):
15
+ headers = {
16
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
17
+ "Accept-Language": "en",
18
+ "Cache-Control": "no-cache",
19
+ "Pragma": "no-cache",
20
+ "Sec-Ch-Ua": '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
21
+ "Sec-Ch-Ua-Mobile": "?0",
22
+ "Sec-Ch-Ua-Platform": '"Windows"',
23
+ "Sec-Fetch-Dest": "document",
24
+ "Sec-Fetch-Mode": "navigate",
25
+ "Sec-Fetch-Site": "none",
26
+ "Sec-Fetch-User": "?1",
27
+ "Upgrade-Insecure-Requests": "1",
28
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
29
+ }
30
+ proxies = {"http": proxy_url, "https": proxy_url} if proxy_url else None
31
+ response = requests.get(property_url, headers=headers, proxies=proxies)
32
+ response.raise_for_status()
33
+ data=parse_body_details_wrapper(response.text)
34
+ return data
pyzill/parse.py ADDED
@@ -0,0 +1,19 @@
1
+ from bs4 import BeautifulSoup
2
+ from pyzill.utils import remove_space
3
+ import json
4
+ import html
5
+
6
+ def parse_body_details_wrapper(body:str):
7
+ soup = BeautifulSoup(body, 'html.parser')
8
+ selections=soup.select("#__NEXT_DATA__")
9
+ if len(selections)==0:
10
+ return {}
11
+ htmlData = soup.select("#__NEXT_DATA__")[0].getText()
12
+ htmlData = remove_space(html.unescape(htmlData))
13
+ data = json.loads(htmlData)
14
+ property=data["props"]["pageProps"]["componentProps"]["gdpClientCache"]
15
+ property = json.loads(property)
16
+ for data in property.values():
17
+ if "property" in data:
18
+ return data["property"]
19
+ return {}
pyzill/search.py ADDED
@@ -0,0 +1,67 @@
1
+ import requests
2
+
3
+ def Search_all(ne_lat:float, ne_long:float, sw_lat:float, sw_long:float, zoom_value:int, proxy_url:str):
4
+ all_results = []
5
+ pagination=0
6
+ while True:
7
+ pagination=pagination+1
8
+ results = search(pagination,ne_lat,ne_long,sw_lat,sw_long,zoom_value,proxy_url)
9
+ all_results = all_results + results
10
+ if len(results)==0:
11
+ break
12
+ return all_results
13
+
14
+ def Search_first_page(ne_lat:float, ne_long:float, sw_lat:float, sw_long:float, zoom_value:int, proxy_url:str):
15
+ results = search(1,ne_lat,ne_long,sw_lat,sw_long,zoom_value,proxy_url)
16
+ return results
17
+
18
+ def search(pagination: int, ne_lat:float, ne_long:float, sw_lat:float, sw_long:float, zoom_value:int, proxy_url:str):
19
+ headers = {
20
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
21
+ "Accept-Language": "en",
22
+ "Cache-Control": "no-cache",
23
+ "Pragma": "no-cache",
24
+ "Sec-Ch-Ua": '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
25
+ "Sec-Ch-Ua-Mobile": "?0",
26
+ "Sec-Ch-Ua-Platform": '"Windows"',
27
+ "Sec-Fetch-Dest": "document",
28
+ "Sec-Fetch-Mode": "navigate",
29
+ "Sec-Fetch-Site": "none",
30
+ "Sec-Fetch-User": "?1",
31
+ "Upgrade-Insecure-Requests": "1",
32
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
33
+ }
34
+ inputData ={
35
+ "searchQueryState":{
36
+ "isMapVisible":False,
37
+ "mapBounds":{
38
+ "west":sw_long,
39
+ "east":ne_long,
40
+ "south":sw_lat,
41
+ "north":ne_lat,
42
+ },
43
+ "filterState":{
44
+ "sortSelection":{
45
+ "value":"globalrelevanceex",
46
+ }
47
+ },
48
+ "isEntirePlaceForRent": True,
49
+ "isRoomForRent": True,
50
+ "isListVisible": True,
51
+ "mapZoom": zoom_value,
52
+ "pagination": {
53
+ "currentPage":pagination,
54
+ },
55
+
56
+ },
57
+ "wants":{
58
+ "cat1":["listResults", "mapResults"],
59
+ "cat2":["total"],
60
+ },
61
+ "requestId": 10,
62
+ "isDebugRequest": False,
63
+ }
64
+ proxies = {"http": proxy_url, "https": proxy_url} if proxy_url else None
65
+ response = requests.put("https://www.zillow.com/async-create-search-page-state", json = inputData, headers=headers, proxies=proxies)
66
+ data = response.json()
67
+ return data["cat1"]["searchResults"]["listResults"]
pyzill/utils.py ADDED
@@ -0,0 +1,36 @@
1
+ import re
2
+
3
+ regex_space = re.compile(r'[\s ]+')
4
+ regx_price = re.compile(r'\d+')
5
+
6
+ def remove_space(value:str):
7
+ return regex_space.sub(' ', value.strip())
8
+
9
+ def get_nested_value(dic, key_path, default=None):
10
+ keys = key_path.split(".")
11
+ current = dic
12
+ for key in keys:
13
+ current = current.get(key, {})
14
+ if current == {} or current is None:
15
+ return default
16
+ return current
17
+
18
+ def parse_price_symbol(price_raw: str):
19
+ price_raw = price_raw.replace(",", "")
20
+
21
+
22
+ price_number_match = regx_price.search(price_raw)
23
+
24
+ if price_number_match is None:
25
+ return 0,""
26
+
27
+ price_number = price_number_match.group(0)
28
+
29
+ price_currency = price_raw.replace(price_number, "").replace(" ", "").replace("-", "")
30
+
31
+ price_converted = float(price_number)
32
+ if price_raw.startswith("-"):
33
+ price_converted *= -1
34
+
35
+ return price_converted, price_currency
36
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 John
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyzill
3
+ Version: 0.0.0
4
+ Summary: Zillow scraper in Python
5
+ Author-email: John Balvin <johnchristian@hotmail.es>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/johnbalvin/pyzill
8
+ Keywords: zillow,scraper,crawler
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: bs4
12
+
13
+ # Zillow scraper in Python
14
+
15
+ ## Overview
16
+ This project is an open-source tool developed in Python for extracting product information from Zillow. It's designed to be easy to use, making it an ideal solution for developers looking for Zillow product data.
17
+
18
+ ## Features
19
+ - Full search support
20
+ - Extracts detailed product information from Zillow
21
+ - Implemented in Python just because it's popular
22
+ - Easy to integrate with existing Python projects
23
+
24
+ ### Install
25
+
26
+ ```bash
27
+ $ pip install pyzill
28
+ ```
29
+ ## Examples
30
+
31
+ ```Python
32
+ import pyzill
33
+ import json
34
+ ne_lat = -1.1225978433925647
35
+ ne_long = -77.59713412765507
36
+ sw_lat = -1.03866277790021
37
+ sw_long = -77.53091734683608
38
+ zoom_value = 2
39
+ results = pyzill.Search_all(ne_lat,ne_long,sw_lat,sw_long,zoom_value, currency,"")
40
+ details_data = []
41
+ progress = 1
42
+ jsondata = json.dumps(results)
43
+ f = open("results.json", "w")
44
+ f.write(jsondata)
45
+ f.close()
46
+ for result in results[:10]:
47
+ data = pyzill.Get_from_room_id(result["room_id"],currency,"")
48
+ details_data.append(data)
49
+ print("len results: ",progress, len(results))
50
+ progress=progress+1
51
+
52
+ details_data_json = json.dumps(details_data)
53
+ f = open("details_data.json", "w")
54
+ f.write(details_data_json)
55
+ f.close()
56
+ ```
57
+
58
+ ```Python
59
+ import pyzill
60
+ import json
61
+ property_url="https://www.zillow.com/homedetails/858-Shady-Grove-Ln-Harrah-OK-73045/339897685_zpid/"
62
+ data = pyzill.Get_from_property_url(property_url,"")
63
+ jsondata = json.dumps(data)
64
+ f = open("details.json", "w")
65
+ f.write(jsondata)
66
+ f.close()
67
+ ```
68
+
69
+ ```Python
70
+ import pyzill
71
+ import json
72
+ property_id=2056016566
73
+ data = pyzill.Get_from_property_url(property_id,"")
74
+ jsondata = json.dumps(data)
75
+ f = open("details.json", "w")
76
+ f.write(jsondata)
77
+ f.close()
78
+ ```
@@ -0,0 +1,10 @@
1
+ pyzill/__init__.py,sha256=4upyy7046j_mHHerrJsfsgRbS6uAs03XkH2iBU1-UXQ,177
2
+ pyzill/details.py,sha256=lGZnybIvpsYbFsAvlMNNURoeTB5KJTEONUR6xjH0dqs,1486
3
+ pyzill/parse.py,sha256=1a4aitlXNO0i20PzNVy0lnWajeSNnUj3zkdeBKCMTWc,641
4
+ pyzill/search.py,sha256=lZ_akKcOpHMYOHkL04n2Ys-o5Z2G7SqY85ZfdXYhU7k,2606
5
+ pyzill/utils.py,sha256=CNp3dZFD2EKT13ijSj7GtwLYPhmblXn6DrlXgJ53-bk,921
6
+ pyzill-0.0.0.dist-info/LICENSE,sha256=0PBfqtVdjTi81KOnoq0jamaIptotvy8HeVisrP8CVCY,1060
7
+ pyzill-0.0.0.dist-info/METADATA,sha256=oTVORLRQx2gqcJmXndn3Pu64Irsc4yLLdB7RT9sHB8E,2000
8
+ pyzill-0.0.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
9
+ pyzill-0.0.0.dist-info/top_level.txt,sha256=_HpmluedFViIWk2sYvNmwH9bELEw1fFjXnSXpilpdag,7
10
+ pyzill-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ pyzill