# Fang.com (房天下) Real Estate Scraper (`crawlerbros/fang-scraper`) Actor

Scrape fang.com - one of China's largest real estate portals. Browse second-hand (sale) listings, rental listings, and new-home projects by city; search listings by keyword; or fetch a single listing/project by URL. Returns title, price, price per sqm, location, rooms, area, images, and publish d...

- **URL**: https://apify.com/crawlerbros/fang-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Real estate, Automation, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Fang.com (房天下) Real Estate Scraper

Scrapes [fang.com](https://www.fang.com) — one of China's largest real estate portals —
for second-hand (sale) listings, rental listings, and new-home projects.

### Data Source

Public HTML pages of `esf.fang.com` (second-hand sales), `zu.fang.com` (rentals),
and `newhouse.fang.com` (new-home projects). No login or API key required.

### Modes

| Mode | Inputs | Source |
|---|---|---|
| `byCity` (default) | `listingType` (sale/rent/newHome), `city`, `rooms`, `sortOrder` | city-subdomain list pages, e.g. `esf.fang.com/house/i1/`, `zu.fang.com/bj/house/i1/`, `newhouse.fang.com/house/s/b2/` |
| `search` | `searchQuery`, `city` | keyword listing search `esf.fang.com/house/kw{kw}/` |
| `byListingUrl` | `listingUrls` | sale `esf.fang.com/chushou/{id}.htm`, rent `zu.fang.com/{city}/chuzu/{type}_{id}_1.htm`, project `newhouse.fang.com/loupan/{id}.htm` |

### Output fields

`sale` / `rent` listings: `title`, `price` (万 CNY for sale, CNY/month for rent),
`pricePerSqm`, `rooms`, `area`, `location`, `community`, `orientation`, `floor`,
`buildYear`, `publishDate`, `images` (verified hotlink-accessible `soufunimg.com`
URLs — real `data-original` lazy-load URLs, never loading placeholders),
`url`, plus `recordType`, `sourceUrl` and `scrapedAt` on every record. Rent
records also carry `rentType` and `tags` (e.g. 周边配套齐 / 采光好).

`newHome` projects: `title`, `status` (在售/待售), `district`, `layout`,
`areaRange`, `pricePerSqm`, `totalPrice`, `location`, `phone`, `images`, `url`.

Detail records (mode=byListingUrl) add: `houseId` / `projectId`, `community`,
`district` (GBK-decoded), `agentName`, `purpose` (esf), `comarea` + `developer`
(newHome).

### Filters

- `minPriceWan` / `maxPriceWan` — price range (client-side, applied to all records)
- `minAreaSqm` / `maxAreaSqm` — area range (client-side)
- `rooms` — 1–5+ bedrooms (server-side for sale; client-side for rent/new-home)
- `sortOrder` — server-side sort for sale/rent lists: default / latest / priceAsc / areaAsc

### Reliability

- Exponential-backoff retries on 429/5xx and on the intermittent timeouts common to
  Chinese CDNs.
- On 403/429 the actor lazily engages the free Apify `AUTO` datacenter proxy group and
  retries.
- fang.com intermittently serves a **JS slider-captcha check wall**
  (`check.3g.fang.com/check.html`) with HTTP 200. The actor detects the wall,
  engages the AUTO proxy, and retries with backoff; if the wall persists it
  emits 0 records with a status message instead of garbage.
- **Filtered-to-zero pagination guard:** when client-side filters (`rooms`,
  `minPriceWan`, `maxPriceWan`, `minAreaSqm`, `maxAreaSqm`) exclude every
  listing on 3 consecutive full pages, pagination stops early instead of
  walking the entire city list, and the actor soft-fails with a status message.
- Invalid listing URLs produce typed `recordType: "error"` records (no silent drops).

### Limitations

- `city` is applied as a subdomain for sale and new-home (`jn.esf.fang.com`,
  `sh.newhouse.fang.com`); rent uses the city in the path (`zu.fang.com/sh/house/`).
  `city=national` browses all cities for sale and new-home; rent has no national
  listing, so it falls back to Beijing (`zu.fang.com/bj/house/`).
- The three listing sites use **different city codes**. The actor auto-maps the
  schema's codes to each site's canonical code (verified Aug 2026), e.g.
  `shenyang` → `sy.esf.fang.com` / `sy.newhouse.fang.com` / `zu.fang.com/sy/`,
  `wh` → `wuhan.esf.fang.com` / `wuhan.newhouse.fang.com` / `zu.fang.com/wuhan/`
  (`wh.esf.fang.com` is a dead host — fang.com's server refuses connections on
  it, so `wh` must map to `wuhan` on every site),
  `su` → `suzhou`, `changsha` → `cs`, `haikou` → `hn`. Requesting an unaliased
  wrong code used to yield a DNS failure (0 records) or — worst case for rent —
  fang.com's silent Beijing fallback page (wrong-city data); both are now
  prevented.
- fang.com has **no coverage for Hohhot and Urumqi** (no esf/newhouse subdomain,
  no zu path): these cities are excluded from the `city` dropdown, and rent
  browse for them emits 0 records with a status message instead of the site's
  Beijing fallback.
- New-home pagination uses `b{page+1}` URL segments observed on `house/s/`.
- List-page images are the site's `224x168c` viewimage thumbnails; detail-page
  galleries are upsized to `512x384c` viewimage variants.

# Actor input Schema

## `mode` (type: `string`):

What to fetch.

## `listingType` (type: `string`):

Kind of listings to browse (mode=byCity).

## `city` (type: `string`):

City code used for the listing browse / search (mode=byCity, mode=search). `national` lists across all cities for sale and new-home; rent has no national listing and falls back to Beijing `bj`. Codes are auto-mapped to each site's canonical code (e.g. `shenyang`→`sy`, `wh`→`wuhan`); hohhot and urumqi are not covered by fang.com and are not offered.

## `searchQuery` (type: `string`):

Keyword to search listings by (mode=search). Matches community names, titles and addresses. e.g. `四龙观`, `亦庄`, `东洲家园`.

## `listingUrls` (type: `array`):

esf.fang.com sale URLs (`https://esf.fang.com/chushou/16_5350069.htm`), zu.fang.com rent URLs (`https://zu.fang.com/bj/chuzu/3_511000130_1.htm`) or newhouse.fang.com project URLs (`https://newhouse.fang.com/loupan/1010187383.htm`).

## `rooms` (type: `string`):

Bedroom count filter. Applied server-side for sale listings; client-side for rent and new-home (mode=byCity).

## `sortOrder` (type: `string`):

List sort applied server-side for sale and rent lists.

## `minPriceWan` (type: `integer`):

Drop listings cheaper than this. Sale prices are in 万; rent prices are in CNY/month (same field, applied as absolute).

## `maxPriceWan` (type: `integer`):

Drop listings more expensive than this.

## `minAreaSqm` (type: `integer`):

Drop listings smaller than this.

## `maxAreaSqm` (type: `integer`):

Drop listings larger than this.

## `maxItems` (type: `integer`):

Hard cap on emitted records.

## Actor input object example

```json
{
  "mode": "byCity",
  "listingType": "sale",
  "city": "national",
  "searchQuery": "亦庄",
  "listingUrls": [],
  "rooms": "any",
  "sortOrder": "default",
  "maxItems": 20
}
```

# Actor output Schema

## `listings` (type: `string`):

Dataset containing all scraped fang.com listings.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "byCity",
    "listingType": "sale",
    "city": "national",
    "searchQuery": "亦庄",
    "listingUrls": [],
    "rooms": "any",
    "sortOrder": "default",
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/fang-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "byCity",
    "listingType": "sale",
    "city": "national",
    "searchQuery": "亦庄",
    "listingUrls": [],
    "rooms": "any",
    "sortOrder": "default",
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/fang-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "byCity",
  "listingType": "sale",
  "city": "national",
  "searchQuery": "亦庄",
  "listingUrls": [],
  "rooms": "any",
  "sortOrder": "default",
  "maxItems": 20
}' |
apify call crawlerbros/fang-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawlerbros/fang-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/CO6eWjihyGlhpv1aq/builds/Qg6U0CnReDaTBgnRx/openapi.json
