TW Rental House Utility for Scrapy
This package is built for crawling Taiwanese rental house related website using Scrapy. As behavior of crawlers may differ from their goal, scale, and pipeline, this package provides only minimum feature set, which allow developer to list and decode a rental house web page into structured data, without knowing too much about detail HTML and API structure of each website. In addition, this package is also designed for extensibility, which allow developers to insert customized callback, manipulate data, and integrate with existing crawler structure.
Although this package provide the ability to crawl rental house website, it's developer's responsibility to ensure crawling mechanism and usage of data. Please be friendly to target website, such as consider using DOWNLOAD_DELAY or AUTO_THROTTLING to prevent bulk requesting.
Requirement
- Python 3.10+
Installation
poetry add scrapy-tw-rental-house
No browser needed. 591 renders both its list and its detail pages on the server, so every page is downloaded by plain HTTP.
591 specific
591 replies 403 to the default scrapy user agent, while it serves requests
carrying no user agent at all just fine, so this package sets USER_AGENT to
None unless the project configures its own.
Tests
Tests run against HTML saved under tests/fixtures, so they neither hit 591
nor need network access. Sockets are blocked while they run, so a test which
crawls by accident fails instead of reaching 591.
poetry install --with dev
poetry run pytest
CLI
The package ships a twrh command for manual testing and monitoring —
plain HTTP, no database, no Scrapy project needed:
twrh parse <saved-detail.html> # offline: run the parser on a saved page
twrh detail <house-id> # fetch + parse one detail page
twrh list 金門縣 # fetch + parse one list page
twrh survey 花蓮縣 # full city sweep → completeness report
twrh harvest 花蓮縣 # stratified fixture harvest + manifest
twrh probe 花蓮縣 # ratio assertions + exit code, for nightly checks
probe asserts on ratios over freshly discovered listings (list volume,
detail success rate, parse rate, key-field fill rates) and can compare
fill rates against a saved survey report via --baseline to catch
silent selector drift. City names follow tw_regions.json; most
subcommands also accept a raw URL or house id.
Basic Usage
This package currently support 591. Each rental house website is a Scrapy Spider class. You can either crawl entire website using default setting , which will take couple days, or customize the behaviour base on your need.
Note: The 591 list spider retrieves houses sorted by post date (newest first), instead of using 591's default ordering. This ensures consistent crawling behavior and helps track newly posted listings.
The most basic usage would be creating a new Spider class that inherit Rental591Spider:
from scrapy_twrh.spiders.rental591 import Rental591Spider
class MyAwesomeSpider(Rental591Spider):
name='awesome'
And than start crawling by
scrapy crawl awesome
Please see example for detail usage.
Items
All spiders populates 2 type of Scrapy items: GenericHouseItem and RawHouseItem.
GenericHouseItem contains normalized data field, spirders from different website will decode their data and fit into this schema in best effort.
RawHouseItem contains unnormalized data field, which keep original and structured data in best effort.
Note that both item are super set of schema. It developer's responsibility to check which field is provided when receiving an item.
For example, in Rental591Spider, for a single rental house, Scrapy will get:
- 1x
RawHouseItem+ 1xGenericHouseItemduring listing all houses, which provide only minimun data field forGenericHouseItem - 1x
RawHouseItem+ 1xGenericHouseItemduring retrieving house detail.
Handlers
All spiders in this package provide the following handlers:
start_list, similiar tostart_requestsin Scrapy, control how crawler issue search/list request to find all rental houses.parse_list, similiar toparsein Scrapy, control how crawler handles response fromstart_listand generate request for detail house info page.parse_detail, control how crawler parse detail page.
All spiders implements their own default handler, say, default_start_list, default_parse_list, and default_parse_detail, and can be overwrite during __init__. Please see example for how to control spider behavior using handlers.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scrapy_tw_rental_house-2.3.0.tar.gz.
File metadata
- Download URL: scrapy_tw_rental_house-2.3.0.tar.gz
- Upload date:
- Size: 46.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.7.1 CPython/3.10.12 Linux/6.8.0-138-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56e8fd62186a9d7034e7bb82cdc3a44eb1a6642a1ea73d379ad55766074aac32
|
|
| MD5 |
dcd229536a12849e45d8a7b7fab788dd
|
|
| BLAKE2b-256 |
4c86faf9114cf79711163e610564cf853d5210df3a98bb192bf8a8e6cf60403b
|
File details
Details for the file scrapy_tw_rental_house-2.3.0-py3-none-any.whl.
File metadata
- Download URL: scrapy_tw_rental_house-2.3.0-py3-none-any.whl
- Upload date:
- Size: 54.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.7.1 CPython/3.10.12 Linux/6.8.0-138-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b1958958b23f0bd8ad1bf1077f4f66474a75674b87c344efc3b652ade54b02d
|
|
| MD5 |
4c096caee5528813c9ed949b0ffd08c1
|
|
| BLAKE2b-256 |
87cbd7b5f81e7e8913c9d44c99d36e8077776d2a4ad93a7b640b054562ae66e2
|