pyhemnet 0.1.0__tar.gz

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.
pyhemnet-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ningdp2012
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,5 @@
1
+ # MANIFEST.in
2
+ include README.md
3
+ include LICENSE
4
+ include pyproject.toml
5
+ recursive-include pyhemnet *.py
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyhemnet
3
+ Version: 0.1.0
4
+ Summary: A Python library for accessing Hemnet.se property data
5
+ Author-email: ningdp2012 <ningdp2012@example.com>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/ningdp2012/pyhemnet
8
+ Keywords: hemnet,real estate,sweden,property,housing,data
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: cloudscraper>=1.2.71
20
+ Requires-Dist: beautifulsoup4>=4.12.0
21
+ Requires-Dist: requests>=2.31.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
24
+ Requires-Dist: black>=23.0.0; extra == "dev"
25
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # PyHemnet
29
+
30
+ A Python library for accessing Hemnet.se property data. Extract property sales information including prices, locations, sizes, and detailed property characteristics.
31
+
32
+ ## Features
33
+
34
+ - 🏠 **Hemnet Data Access**: Access property sales data from Hemnet.se
35
+ - Get summary statistics on properties for sale and sold properties
36
+ - Extract detailed information including prices, location, size, broker, and more
37
+ - Filter by location and property types
38
+ - Support for multiple property types (villa, radhus, bostadsrätt, etc.)
39
+
40
+ - 🚀 Easy-to-use Python API
41
+ - 💻 Object-oriented design with clean interfaces
42
+
43
+ ## Installation
44
+
45
+ Install from PyPI:
46
+
47
+ ```bash
48
+ pip install pyhemnet
49
+ ```
50
+
51
+ Or install from source:
52
+
53
+ ```bash
54
+ git clone https://github.com/ningdp2012/pyhemnet.git
55
+ cd pyhemnet
56
+ pip install -e .
57
+ ```
58
+
59
+ ## Quick Start
60
+
61
+ ```python
62
+ from pyhemnet import HemnetScraper, HemnetItemType
63
+
64
+ # Create a scraper instance
65
+ scraper = HemnetScraper()
66
+
67
+ # Get summary statistics
68
+ listing_count, sold_count = scraper.get_summary(location_id="17744")
69
+ print(f"Properties for sale: {listing_count}")
70
+ print(f"Sold properties: {sold_count}")
71
+
72
+ # Get detailed sold properties
73
+ homes = scraper.get_sold(
74
+ location_id="17744",
75
+ item_types=[HemnetItemType.VILLA, HemnetItemType.RADHUS]
76
+ )
77
+
78
+ for home in homes:
79
+ print(f"{home['address']} - {home['final_price']} SEK")
80
+ ```
81
+
82
+ ## Usage
83
+
84
+ ### Initialize the Scraper
85
+
86
+ ```python
87
+ from pyhemnet import HemnetScraper, HemnetItemType
88
+
89
+ scraper = HemnetScraper()
90
+ ```
91
+
92
+ ### Get Summary Statistics
93
+
94
+ Get counts of properties for sale and sold:
95
+
96
+ ```python
97
+ # Get summary for a specific location
98
+ listing_count, sold_count = scraper.get_summary(location_id="17744")
99
+ print(f"For sale: {listing_count}, Sold: {sold_count}")
100
+
101
+ # Filter by property types
102
+ listing_count, sold_count = scraper.get_summary(
103
+ location_id="17744",
104
+ item_types=[HemnetItemType.VILLA]
105
+ )
106
+ ```
107
+
108
+ ### Get Sold Properties
109
+
110
+ Retrieve detailed information about sold properties:
111
+
112
+ ```python
113
+ homes = scraper.get_sold(
114
+ location_id="17744",
115
+ item_types=[HemnetItemType.VILLA, HemnetItemType.RADHUS]
116
+ )
117
+
118
+ for home in homes:
119
+ print(f"Address: {home['address']}")
120
+ print(f"Final price: {home['final_price']} SEK")
121
+ print(f"Asking price: {home['asking_price']} SEK")
122
+ print(f"Living area: {home['living_area']}")
123
+ print(f"Sold date: {home['sold_at']}")
124
+ print("---")
125
+ ```
126
+
127
+ ### Get Current Listings
128
+
129
+ Get properties currently for sale:
130
+
131
+ ```python
132
+ listings = scraper.get_listings(
133
+ location_id="17744",
134
+ item_types=[HemnetItemType.BOSTADSRATT]
135
+ )
136
+
137
+ for listing in listings:
138
+ print(f"Address: {listing['address']}")
139
+ print(f"Price: {listing['asking_price']} SEK")
140
+ print(f"Published: {listing['published_at']}")
141
+ ```
142
+
143
+ ### Property Types
144
+
145
+ Use the `HemnetItemType` enum or strings:
146
+
147
+ ```python
148
+ # Using enum (recommended)
149
+ item_types = [HemnetItemType.VILLA, HemnetItemType.RADHUS]
150
+
151
+ # Using strings
152
+ item_types = ["villa", "radhus"]
153
+ ```
154
+
155
+ Available types:
156
+ - `VILLA` - Detached houses
157
+ - `RADHUS` - Townhouses
158
+ - `BOSTADSRATT` - Condominiums
159
+ - `FRITIDSHUS` - Vacation homes
160
+ - `TOMT` - Land plots
161
+ - `GARD` - Farms
162
+ - `OTHER` - Other property types
163
+
164
+ ## Data Structure
165
+
166
+ ### Sold Property Data
167
+
168
+ Each sold property dictionary contains:
169
+
170
+ ```python
171
+ {
172
+ 'id': str, # Hemnet ID
173
+ 'listing_id': str, # Listing identifier
174
+ 'address': str, # Street address
175
+ 'location': str, # Location description
176
+ 'housing_type': str, # Type of housing (Villa, Radhus, etc.)
177
+ 'rooms': int, # Number of rooms
178
+ 'living_area': str, # Living area with units
179
+ 'land_area': str, # Land area with units
180
+ 'asking_price': int, # Initial asking price in SEK
181
+ 'final_price': int, # Final sold price in SEK
182
+ 'price_change': str, # Price change information
183
+ 'sold_at': str, # Sale date (YYYY-MM-DD format)
184
+ 'broker': str, # Broker agency name
185
+ 'labels': list, # List of property labels/tags
186
+ }
187
+ ```
188
+
189
+ ### Current Listing Data
190
+
191
+ Each listing dictionary contains:
192
+
193
+ ```python
194
+ {
195
+ 'id': str, # Hemnet ID
196
+ 'address': str, # Street address
197
+ 'location': str, # Location description
198
+ 'housing_type': str, # Type of housing
199
+ 'rooms': int, # Number of rooms
200
+ 'living_area': str, # Living area with units
201
+ 'land_area': str, # Land area with units
202
+ 'asking_price': int, # Asking price in SEK
203
+ 'published_at': str, # Publication date (YYYY-MM-DD)
204
+ 'removed_before_showing': bool, # Removed before showing
205
+ 'new_construction': bool, # New construction flag
206
+ 'broker_name': str, # Broker name
207
+ 'broker_agent': str, # Broker agency name
208
+ 'labels': list, # List of property labels/tags
209
+ 'description': str, # Property description
210
+ }
211
+ ```
212
+
213
+ ## Finding Location IDs
214
+
215
+ To find Hemnet location IDs:
216
+
217
+ 1. Go to [Hemnet.se](https://www.hemnet.se)
218
+ 2. Search for your desired location
219
+ 3. Look at the URL - it contains `location_ids[]=XXXXX`
220
+ 4. Use that ID in your code
221
+
222
+ Example: For Stockholm `https://www.hemnet.se/bostader?location_ids[]=17744`, use `location_id="17744"`
223
+
224
+ ## Requirements
225
+
226
+ - Python 3.10+
227
+ - cloudscraper >= 1.2.71
228
+ - beautifulsoup4 >= 4.12.0
229
+ - requests >= 2.31.0
230
+
231
+ ## Contributing
232
+
233
+ Contributions are welcome! Please feel free to submit a Pull Request.
234
+
235
+ ## License
236
+
237
+ This project is licensed under the MIT License - see the LICENSE file for details.
238
+
239
+ ## Disclaimer
240
+
241
+ This package is created for exploring python and web technologies and learning purposes only. It is **not intended for production use** or commercial applications.
242
+
243
+ - This is an unofficial package and is not affiliated with or endorsed by Hemnet AB
244
+ - Always respect website terms of service and robots.txt directives
245
+ - Web scraping may be subject to legal restrictions in your jurisdiction
246
+ - Use at your own risk and responsibility
@@ -0,0 +1,219 @@
1
+ # PyHemnet
2
+
3
+ A Python library for accessing Hemnet.se property data. Extract property sales information including prices, locations, sizes, and detailed property characteristics.
4
+
5
+ ## Features
6
+
7
+ - 🏠 **Hemnet Data Access**: Access property sales data from Hemnet.se
8
+ - Get summary statistics on properties for sale and sold properties
9
+ - Extract detailed information including prices, location, size, broker, and more
10
+ - Filter by location and property types
11
+ - Support for multiple property types (villa, radhus, bostadsrätt, etc.)
12
+
13
+ - 🚀 Easy-to-use Python API
14
+ - 💻 Object-oriented design with clean interfaces
15
+
16
+ ## Installation
17
+
18
+ Install from PyPI:
19
+
20
+ ```bash
21
+ pip install pyhemnet
22
+ ```
23
+
24
+ Or install from source:
25
+
26
+ ```bash
27
+ git clone https://github.com/ningdp2012/pyhemnet.git
28
+ cd pyhemnet
29
+ pip install -e .
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ```python
35
+ from pyhemnet import HemnetScraper, HemnetItemType
36
+
37
+ # Create a scraper instance
38
+ scraper = HemnetScraper()
39
+
40
+ # Get summary statistics
41
+ listing_count, sold_count = scraper.get_summary(location_id="17744")
42
+ print(f"Properties for sale: {listing_count}")
43
+ print(f"Sold properties: {sold_count}")
44
+
45
+ # Get detailed sold properties
46
+ homes = scraper.get_sold(
47
+ location_id="17744",
48
+ item_types=[HemnetItemType.VILLA, HemnetItemType.RADHUS]
49
+ )
50
+
51
+ for home in homes:
52
+ print(f"{home['address']} - {home['final_price']} SEK")
53
+ ```
54
+
55
+ ## Usage
56
+
57
+ ### Initialize the Scraper
58
+
59
+ ```python
60
+ from pyhemnet import HemnetScraper, HemnetItemType
61
+
62
+ scraper = HemnetScraper()
63
+ ```
64
+
65
+ ### Get Summary Statistics
66
+
67
+ Get counts of properties for sale and sold:
68
+
69
+ ```python
70
+ # Get summary for a specific location
71
+ listing_count, sold_count = scraper.get_summary(location_id="17744")
72
+ print(f"For sale: {listing_count}, Sold: {sold_count}")
73
+
74
+ # Filter by property types
75
+ listing_count, sold_count = scraper.get_summary(
76
+ location_id="17744",
77
+ item_types=[HemnetItemType.VILLA]
78
+ )
79
+ ```
80
+
81
+ ### Get Sold Properties
82
+
83
+ Retrieve detailed information about sold properties:
84
+
85
+ ```python
86
+ homes = scraper.get_sold(
87
+ location_id="17744",
88
+ item_types=[HemnetItemType.VILLA, HemnetItemType.RADHUS]
89
+ )
90
+
91
+ for home in homes:
92
+ print(f"Address: {home['address']}")
93
+ print(f"Final price: {home['final_price']} SEK")
94
+ print(f"Asking price: {home['asking_price']} SEK")
95
+ print(f"Living area: {home['living_area']}")
96
+ print(f"Sold date: {home['sold_at']}")
97
+ print("---")
98
+ ```
99
+
100
+ ### Get Current Listings
101
+
102
+ Get properties currently for sale:
103
+
104
+ ```python
105
+ listings = scraper.get_listings(
106
+ location_id="17744",
107
+ item_types=[HemnetItemType.BOSTADSRATT]
108
+ )
109
+
110
+ for listing in listings:
111
+ print(f"Address: {listing['address']}")
112
+ print(f"Price: {listing['asking_price']} SEK")
113
+ print(f"Published: {listing['published_at']}")
114
+ ```
115
+
116
+ ### Property Types
117
+
118
+ Use the `HemnetItemType` enum or strings:
119
+
120
+ ```python
121
+ # Using enum (recommended)
122
+ item_types = [HemnetItemType.VILLA, HemnetItemType.RADHUS]
123
+
124
+ # Using strings
125
+ item_types = ["villa", "radhus"]
126
+ ```
127
+
128
+ Available types:
129
+ - `VILLA` - Detached houses
130
+ - `RADHUS` - Townhouses
131
+ - `BOSTADSRATT` - Condominiums
132
+ - `FRITIDSHUS` - Vacation homes
133
+ - `TOMT` - Land plots
134
+ - `GARD` - Farms
135
+ - `OTHER` - Other property types
136
+
137
+ ## Data Structure
138
+
139
+ ### Sold Property Data
140
+
141
+ Each sold property dictionary contains:
142
+
143
+ ```python
144
+ {
145
+ 'id': str, # Hemnet ID
146
+ 'listing_id': str, # Listing identifier
147
+ 'address': str, # Street address
148
+ 'location': str, # Location description
149
+ 'housing_type': str, # Type of housing (Villa, Radhus, etc.)
150
+ 'rooms': int, # Number of rooms
151
+ 'living_area': str, # Living area with units
152
+ 'land_area': str, # Land area with units
153
+ 'asking_price': int, # Initial asking price in SEK
154
+ 'final_price': int, # Final sold price in SEK
155
+ 'price_change': str, # Price change information
156
+ 'sold_at': str, # Sale date (YYYY-MM-DD format)
157
+ 'broker': str, # Broker agency name
158
+ 'labels': list, # List of property labels/tags
159
+ }
160
+ ```
161
+
162
+ ### Current Listing Data
163
+
164
+ Each listing dictionary contains:
165
+
166
+ ```python
167
+ {
168
+ 'id': str, # Hemnet ID
169
+ 'address': str, # Street address
170
+ 'location': str, # Location description
171
+ 'housing_type': str, # Type of housing
172
+ 'rooms': int, # Number of rooms
173
+ 'living_area': str, # Living area with units
174
+ 'land_area': str, # Land area with units
175
+ 'asking_price': int, # Asking price in SEK
176
+ 'published_at': str, # Publication date (YYYY-MM-DD)
177
+ 'removed_before_showing': bool, # Removed before showing
178
+ 'new_construction': bool, # New construction flag
179
+ 'broker_name': str, # Broker name
180
+ 'broker_agent': str, # Broker agency name
181
+ 'labels': list, # List of property labels/tags
182
+ 'description': str, # Property description
183
+ }
184
+ ```
185
+
186
+ ## Finding Location IDs
187
+
188
+ To find Hemnet location IDs:
189
+
190
+ 1. Go to [Hemnet.se](https://www.hemnet.se)
191
+ 2. Search for your desired location
192
+ 3. Look at the URL - it contains `location_ids[]=XXXXX`
193
+ 4. Use that ID in your code
194
+
195
+ Example: For Stockholm `https://www.hemnet.se/bostader?location_ids[]=17744`, use `location_id="17744"`
196
+
197
+ ## Requirements
198
+
199
+ - Python 3.10+
200
+ - cloudscraper >= 1.2.71
201
+ - beautifulsoup4 >= 4.12.0
202
+ - requests >= 2.31.0
203
+
204
+ ## Contributing
205
+
206
+ Contributions are welcome! Please feel free to submit a Pull Request.
207
+
208
+ ## License
209
+
210
+ This project is licensed under the MIT License - see the LICENSE file for details.
211
+
212
+ ## Disclaimer
213
+
214
+ This package is created for exploring python and web technologies and learning purposes only. It is **not intended for production use** or commercial applications.
215
+
216
+ - This is an unofficial package and is not affiliated with or endorsed by Hemnet AB
217
+ - Always respect website terms of service and robots.txt directives
218
+ - Web scraping may be subject to legal restrictions in your jurisdiction
219
+ - Use at your own risk and responsibility
@@ -0,0 +1,15 @@
1
+ """Swedish Real Estate Scraper - Scrape data from Hemnet.se"""
2
+
3
+ __version__ = "0.1.0"
4
+ __author__ = "ningdp2012"
5
+
6
+ # Import scraper classes
7
+ from .hemnet import HemnetScraper
8
+
9
+ # Import enums
10
+ from .constants import HemnetItemType
11
+
12
+ __all__ = [
13
+ "HemnetScraper",
14
+ "HemnetItemType",
15
+ ]
@@ -0,0 +1,21 @@
1
+ """Constants for Hemnet scraper"""
2
+
3
+ from enum import Enum
4
+
5
+
6
+ class HemnetItemType(str, Enum):
7
+ """Hemnet property item types"""
8
+ VILLA = "villa"
9
+ RADHUS = "radhus"
10
+ BOSTADSRATT = "bostadsratt"
11
+ FRITIDSHUS = "fritidshus"
12
+ TOMT = "tomt"
13
+ GARD = "gard"
14
+ OTHER = "other"
15
+
16
+
17
+ # Hemnet URLs mapping
18
+ HEMNET_URLS = {
19
+ "listings": "https://www.hemnet.se/bostader",
20
+ "sold": "https://www.hemnet.se/salda/bostader"
21
+ }