@pencil-agent/nano-pencil 2.0.0 → 2.0.1

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.
Files changed (195) hide show
  1. package/README.md +267 -267
  2. package/dist/build-meta.json +3 -3
  3. package/dist/core/export-html/AGENT.md +11 -11
  4. package/dist/core/export-html/template.css +971 -971
  5. package/dist/core/export-html/template.html +54 -54
  6. package/dist/core/mcp/mcp-client.d.ts +3 -1
  7. package/dist/core/mcp/mcp-client.js +6 -6
  8. package/dist/core/mcp/mcp-config.d.ts +3 -3
  9. package/dist/core/mcp/mcp-config.js +1 -1
  10. package/dist/core/mcp/mcp-manager.d.ts +5 -1
  11. package/dist/core/mcp/mcp-manager.js +1 -1
  12. package/dist/core/platform/config/resource-loader.d.ts +2 -0
  13. package/dist/core/platform/config/resource-loader.js +2 -2
  14. package/dist/core/runtime/agent-session.d.ts +12 -0
  15. package/dist/core/runtime/agent-session.js +8 -8
  16. package/dist/core/runtime/sdk.d.ts +8 -0
  17. package/dist/core/runtime/sdk.js +1 -1
  18. package/dist/extensions/builtin/AGENT.md +115 -115
  19. package/dist/extensions/builtin/browser/AGENT.md +17 -17
  20. package/dist/extensions/builtin/browser/agent-workspace/agent_helpers.py +12 -12
  21. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/amazon/product-search.md +198 -198
  22. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/archive-org/scraping.md +341 -341
  23. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv/scraping.md +311 -311
  24. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv-bulk/scraping.md +333 -333
  25. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/atlas/overview.md +70 -70
  26. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/booking-com/scraping.md +578 -578
  27. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/capterra/scraping.md +440 -440
  28. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/centilebrain/generate-estimates.md +110 -110
  29. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coingecko/scraping.md +325 -325
  30. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coinmarketcap/scraping.md +463 -463
  31. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coursera/scraping.md +360 -360
  32. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/craigslist/scraping.md +390 -390
  33. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/crossref/scraping.md +568 -568
  34. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/dev-to/scraping.md +323 -323
  35. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/duckduckgo/scraping.md +349 -349
  36. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/ebay/scraping.md +435 -435
  37. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/etsy/scraping.md +506 -506
  38. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/eventbrite/scraping.md +363 -363
  39. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/expedia/automation.md +168 -168
  40. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/groups.md +236 -236
  41. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/pages.md +295 -295
  42. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/framer/editor.md +108 -108
  43. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/fred/scraping.md +493 -493
  44. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/g2/scraping.md +580 -580
  45. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/genius/scraping.md +511 -511
  46. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/repo-actions.md +65 -65
  47. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/scraping.md +184 -184
  48. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/glassdoor/scraping.md +543 -543
  49. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gmail/compose.md +122 -122
  50. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/goodreads/scraping.md +461 -461
  51. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gutenberg/scraping.md +383 -383
  52. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/hackernews/scraping.md +243 -243
  53. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/howlongtobeat/scraping.md +473 -473
  54. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/imdb/scraping.md +271 -271
  55. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/itch-io/scraping.md +436 -436
  56. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/job-boards/indeed-glassdoor.md +1021 -1021
  57. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/letterboxd/scraping.md +349 -349
  58. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/linkedin/invitation-manager.md +109 -109
  59. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/loom/folder-enumeration.md +170 -170
  60. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/macrotrends/scraping.md +537 -537
  61. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/article-hydration.md +120 -120
  62. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/scraping.md +414 -414
  63. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/metacritic/scraping.md +477 -477
  64. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/musicbrainz/scraping.md +478 -478
  65. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/nasa/scraping.md +339 -339
  66. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/news-aggregation/multi-source.md +205 -205
  67. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/open-library/scraping.md +472 -472
  68. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openalex/scraping.md +470 -470
  69. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openstreetmap/scraping.md +490 -490
  70. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/package-registries/npm-pypi.md +478 -478
  71. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/polymarket/scraping.md +234 -234
  72. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/producthunt/scraping.md +307 -307
  73. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/pubmed/scraping.md +421 -421
  74. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/quora/scraping.md +364 -364
  75. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rawg/scraping.md +352 -352
  76. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/reddit/scraping.md +124 -124
  77. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rest-countries/scraping.md +233 -233
  78. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/sec-edgar/scraping.md +361 -361
  79. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/README.md +36 -36
  80. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/embedded-apps.md +72 -72
  81. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/knowledge-base.md +109 -109
  82. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/polaris-inputs.md +137 -137
  83. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/soundcloud/scraping.md +362 -362
  84. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/spotify/scraping.md +339 -339
  85. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/stackoverflow/scraping.md +435 -435
  86. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/steam/scraping.md +575 -575
  87. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/substack/scraping.md +338 -338
  88. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/thetechgeeks/pricing.md +52 -52
  89. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tiktok/upload.md +107 -107
  90. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tradingview/scraping.md +309 -309
  91. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trello/boards-and-lists.md +88 -88
  92. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trustpilot/scraping.md +375 -375
  93. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/walmart/scraping.md +444 -444
  94. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wayback-machine/scraping.md +306 -306
  95. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/weather/scraping.md +398 -398
  96. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wellfound/scraping.md +596 -596
  97. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/world-bank/scraping.md +356 -356
  98. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/xiaohongshu/scraping.md +84 -84
  99. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/youtube/scraping.md +418 -418
  100. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/zillow/scraping.md +433 -433
  101. package/dist/extensions/builtin/browser/browser.md +73 -73
  102. package/dist/extensions/builtin/browser/install.md +142 -142
  103. package/dist/extensions/builtin/browser/interaction-skills/connection.md +48 -48
  104. package/dist/extensions/builtin/browser/interaction-skills/cookies.md +3 -3
  105. package/dist/extensions/builtin/browser/interaction-skills/cross-origin-iframes.md +3 -3
  106. package/dist/extensions/builtin/browser/interaction-skills/dialogs.md +64 -64
  107. package/dist/extensions/builtin/browser/interaction-skills/downloads.md +3 -3
  108. package/dist/extensions/builtin/browser/interaction-skills/drag-and-drop.md +3 -3
  109. package/dist/extensions/builtin/browser/interaction-skills/dropdowns.md +3 -3
  110. package/dist/extensions/builtin/browser/interaction-skills/iframes.md +3 -3
  111. package/dist/extensions/builtin/browser/interaction-skills/network-requests.md +3 -3
  112. package/dist/extensions/builtin/browser/interaction-skills/print-as-pdf.md +3 -3
  113. package/dist/extensions/builtin/browser/interaction-skills/profile-sync.md +90 -90
  114. package/dist/extensions/builtin/browser/interaction-skills/screenshots.md +17 -17
  115. package/dist/extensions/builtin/browser/interaction-skills/scrolling.md +3 -3
  116. package/dist/extensions/builtin/browser/interaction-skills/shadow-dom.md +3 -3
  117. package/dist/extensions/builtin/browser/interaction-skills/tabs.md +69 -69
  118. package/dist/extensions/builtin/browser/interaction-skills/uploads.md +1 -1
  119. package/dist/extensions/builtin/browser/interaction-skills/viewport.md +3 -3
  120. package/dist/extensions/builtin/browser/src/browser_harness/AGENT.md +15 -15
  121. package/dist/extensions/builtin/browser/src/browser_harness/__init__.py +8 -8
  122. package/dist/extensions/builtin/browser/src/browser_harness/_ipc.py +90 -90
  123. package/dist/extensions/builtin/browser/src/browser_harness/admin.py +722 -722
  124. package/dist/extensions/builtin/browser/src/browser_harness/daemon.py +328 -328
  125. package/dist/extensions/builtin/browser/src/browser_harness/helpers.py +396 -396
  126. package/dist/extensions/builtin/browser/src/browser_harness/run.py +103 -103
  127. package/dist/extensions/builtin/discipline/skills/brainstorming/SKILL.md +33 -33
  128. package/dist/extensions/builtin/discipline/skills/executing-plans/SKILL.md +25 -25
  129. package/dist/extensions/builtin/discipline/skills/finishing-development-branch/SKILL.md +25 -25
  130. package/dist/extensions/builtin/discipline/skills/receiving-code-review/SKILL.md +22 -22
  131. package/dist/extensions/builtin/discipline/skills/requesting-code-review/SKILL.md +31 -31
  132. package/dist/extensions/builtin/discipline/skills/systematic-debugging/SKILL.md +28 -28
  133. package/dist/extensions/builtin/discipline/skills/test-driven-development/SKILL.md +32 -32
  134. package/dist/extensions/builtin/discipline/skills/using-git-worktrees/SKILL.md +25 -25
  135. package/dist/extensions/builtin/discipline/skills/verification-before-completion/SKILL.md +27 -27
  136. package/dist/extensions/builtin/discipline/skills/writing-plans/SKILL.md +26 -26
  137. package/dist/extensions/builtin/goal/README.md +67 -67
  138. package/dist/extensions/builtin/grub/README.md +112 -112
  139. package/dist/extensions/builtin/link-world/agent-workspace/README.md +16 -16
  140. package/dist/extensions/builtin/link-world/internet-search/internet-search.md +65 -65
  141. package/dist/extensions/builtin/link-world/link-world-agent.md +82 -82
  142. package/dist/extensions/builtin/link-world/linkworld.md +313 -313
  143. package/dist/extensions/builtin/link-world/network-routing/network-routing.md +67 -67
  144. package/dist/extensions/builtin/loop/README.md +92 -92
  145. package/dist/extensions/builtin/mcp/figma-design.md +68 -68
  146. package/dist/extensions/builtin/mcp/mcp-management.md +85 -85
  147. package/dist/extensions/builtin/recap/AGENT.md +15 -15
  148. package/dist/extensions/builtin/sal/README.md +72 -72
  149. package/dist/extensions/builtin/security-audit/README.md +289 -289
  150. package/dist/extensions/builtin/team/AGENT.md +112 -112
  151. package/dist/extensions/builtin/team/TESTING.md +299 -299
  152. package/dist/extensions/builtin/token-save/README.md +56 -56
  153. package/dist/extensions/optional/AGENT.md +10 -10
  154. package/dist/modes/interactive/interactive-mode.js +36 -36
  155. package/dist/modes/interactive/theme/dark.json +85 -85
  156. package/dist/modes/interactive/theme/light.json +84 -84
  157. package/dist/modes/interactive/theme/theme-schema.json +335 -335
  158. package/dist/modes/interactive/theme/warm.json +81 -81
  159. package/dist/node_modules/@pencil-agent/agent-core/dist/agent-loop.js +3 -2
  160. package/dist/node_modules/@pencil-agent/agent-core/dist/structured-adaptive-agent-loop.js +2 -1
  161. package/dist/node_modules/@pencil-agent/ai/dist/cli.js +0 -0
  162. package/docs/cc-agent-design.md +1297 -0
  163. package/docs/cc-tui-design.md +1333 -0
  164. package/docs/codex-goal-command-impl.md +1055 -1055
  165. package/docs/codex-goal-vs-grub.md +500 -500
  166. package/docs/custom-provider.md +27 -27
  167. package/docs/extensions.md +27 -27
  168. package/docs/keybindings.md +27 -27
  169. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/200/273/347/273/223.md" +250 -250
  170. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/212/245/345/221/212.md" +122 -122
  171. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210.md" +1222 -1222
  172. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210/345/256/236/347/216/260/346/212/245/345/221/212.md" +158 -158
  173. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210/345/257/271/346/257/224/345/210/206/346/236/220.md" +128 -128
  174. package/docs/loop /351/207/215/346/236/204/350/256/241/345/210/222.md" +320 -320
  175. package/docs/loop-usage-examples.md +214 -214
  176. package/docs/models.md +27 -27
  177. package/docs/nanoPencil-/345/255/246/344/271/240/350/256/241/345/210/222.md +170 -0
  178. package/docs/packages.md +27 -27
  179. package/docs/pi-design-philosophy.md +457 -457
  180. package/docs/planmode.md +1987 -1987
  181. package/docs/prompt-templates.md +27 -27
  182. package/docs/providers.md +27 -27
  183. package/docs/scan-report.md +3820 -0
  184. package/docs/sdk.md +27 -27
  185. package/docs/skills.md +27 -27
  186. package/docs/themes.md +27 -27
  187. package/docs/tui.md +27 -27
  188. package/docs//345/257/271/346/240/207Claude-Code.md +1775 -0
  189. package/docs//351/230/277/351/207/214/345/267/264/345/267/264/350/264/242/346/212/245/345/210/206/346/236/220/344/271/246.md +261 -0
  190. package/package.json +190 -190
  191. package/docs/ACP/345/215/217/350/256/256/351/233/206/346/210/220/345/274/200/345/217/221/346/226/207/346/241/243.md +0 -851
  192. package/docs/SDK-TESTING.md +0 -364
  193. package/docs/mem-core/346/212/200/346/234/257/346/226/207/346/241/243.md +0 -593
  194. package/docs/startup-performance-optimization.md +0 -301
  195. package/docs//350/256/244/347/237/245/345/234/260/345/233/276.md +0 -47
@@ -1,390 +1,390 @@
1
- # Craigslist — Scraping via http_get
2
-
3
- Field-tested against sfbay.craigslist.org and multiple city subdomains on 2026-04-18.
4
- `http_get` works without any bot detection — no CAPTCHA, no block, no rate limit observed.
5
- Craigslist serves a full server-rendered HTML fallback (the `<ol class="cl-static-search-results">` block)
6
- intended for no-JS browsers. This fallback contains **all matching results in one response** (300–360
7
- items typical), regardless of the `s=` offset parameter. No browser needed.
8
-
9
- ## Key discovery: static HTML returns everything at once
10
-
11
- When you `http_get` a Craigslist search URL, the server includes a `<ol class="cl-static-search-results">`
12
- block that contains every matching listing (up to ~360) in a single HTML response. The `s=` pagination
13
- parameter is ignored by the static renderer — it is only meaningful for the JS-driven XHR path used by
14
- real browsers. For scraping purposes, this means:
15
-
16
- - One `http_get` call per search query returns the full result set (no pagination loop needed).
17
- - For broader searches, narrow via `query=`, `min_price=`, `max_price=`, and category code in the URL.
18
- - If you need more than ~360 results, you must use a headless browser with JS. For most tasks,
19
- one request is sufficient.
20
-
21
- ## URL patterns
22
-
23
- ### City subdomains
24
- ```
25
- https://{city}.craigslist.org/search/{category_code}?query=...
26
- ```
27
-
28
- Confirmed working cities (exact subdomain names):
29
-
30
- | City | Subdomain |
31
- |----------------|------------------|
32
- | SF Bay Area | `sfbay` |
33
- | New York | `newyork` |
34
- | Chicago | `chicago` |
35
- | Los Angeles | `losangeles` |
36
- | Seattle | `seattle` |
37
- | Boston | `boston` |
38
- | Miami | `miami` |
39
- | Denver | `denver` |
40
- | Austin | `austin` |
41
- | Portland | `portland` |
42
- | San Diego | `sandiego` |
43
- | Phoenix | `phoenix` |
44
-
45
- ### Category codes (confirmed working)
46
-
47
- | Code | Category |
48
- |-------|---------------------------|
49
- | `sss` | For Sale — all |
50
- | `for` | For Sale — general |
51
- | `ela` | Electronics (listings) |
52
- | `ele` | Electronics (search) |
53
- | `fua` | Furniture |
54
- | `clo` | Clothing & accessories |
55
- | `spo` | Sporting goods |
56
- | `toy` | Toys & games |
57
- | `cto` | Cars+trucks — by owner |
58
- | `cta` | Cars+trucks — by dealer |
59
- | `hhh` | Housing — all |
60
- | `apa` | Apartments |
61
- | `roo` | Rooms & shares |
62
- | `sub` | Sublets & temporary |
63
- | `jjj` | Jobs — all |
64
- | `sof` | Software/QA/DBA jobs |
65
- | `bbb` | Services — all |
66
- | `ggg` | Gigs — all |
67
- | `com` | Community |
68
- | `eve` | Events |
69
- | `vol` | Volunteers |
70
-
71
- ### Query parameters
72
-
73
- | Parameter | Effect |
74
- |---------------|------------------------------------------------|
75
- | `query=` | Keyword search |
76
- | `sort=rel` | Sort by relevance (default) |
77
- | `sort=date` | Sort by newest first |
78
- | `sort=priceasc` | Price low to high |
79
- | `sort=pricedsc` | Price high to low |
80
- | `min_price=` | Minimum price filter |
81
- | `max_price=` | Maximum price filter |
82
- | `condition=10` | New (for-sale listings) |
83
- | `condition=20` | Like new |
84
- | `condition=30` | Excellent |
85
- | `condition=40` | Good |
86
- | `condition=50` | Fair |
87
- | `condition=60` | Salvage |
88
- | `bedrooms=` | Number of bedrooms (housing only) |
89
- | `auto_make_model=` | Car make/model filter (cars category) |
90
- | `s=` | Pagination offset — **ignored in static HTML** |
91
-
92
- ### Example URLs
93
- ```python
94
- # For-sale keyword search
95
- "https://sfbay.craigslist.org/search/sss?query=macbook&sort=rel"
96
-
97
- # Price-filtered electronics
98
- "https://sfbay.craigslist.org/search/ela?query=iphone&min_price=100&max_price=500"
99
-
100
- # Apartments, 2 bedrooms, price range
101
- "https://sfbay.craigslist.org/search/apa?bedrooms=2&min_price=1000&max_price=2500"
102
-
103
- # Cars by owner, Toyota
104
- "https://sfbay.craigslist.org/search/cto?auto_make_model=toyota"
105
-
106
- # Jobs in another city
107
- "https://chicago.craigslist.org/search/jjj?query=python+developer"
108
- ```
109
-
110
- ## Listing card HTML structure
111
-
112
- Each listing is an `<li class="cl-static-search-result">` inside `<ol class="cl-static-search-results">`.
113
-
114
- ```html
115
- <li class="cl-static-search-result" title="MacBook Air M2 256GB 8GB RAM">
116
- <a href="https://sfbay.craigslist.org/sby/ele/d/san-jose-macbook-air-m2/7928508295.html">
117
- <div class="title">MacBook Air M2 256GB 8GB RAM</div>
118
- <div class="details">
119
- <div class="price">$900</div>
120
- <div class="location">San Jose</div>
121
- </div>
122
- </a>
123
- </li>
124
- ```
125
-
126
- Fields available in the listing card:
127
- - **Title**: `title` attribute on `<li>` OR text inside `<div class="title">`
128
- - **URL**: `href` on the `<a>` tag — always a full absolute URL
129
- - **Price**: `<div class="price">` — may be absent on free/contact-for-price listings
130
- - **Location/neighborhood**: `<div class="location">` — neighborhood name or city
131
- - **Post ID**: last segment of the URL before `.html` (e.g. `/7928508295.html` → `7928508295`)
132
-
133
- URL pattern: `https://{city}.craigslist.org/{area}/{category_code}/d/{slug}/{post_id}.html`
134
-
135
- ## Parsing search results (field-tested)
136
-
137
- ```python
138
- import re
139
- from helpers import http_get
140
-
141
- def search_craigslist(city, category, query, min_price=None, max_price=None):
142
- params = f"query={query.replace(' ', '+')}&sort=rel"
143
- if min_price: params += f"&min_price={min_price}"
144
- if max_price: params += f"&max_price={max_price}"
145
- url = f"https://{city}.craigslist.org/search/{category}?{params}"
146
- headers = {"User-Agent": "Mozilla/5.0"}
147
- html = http_get(url, headers=headers)
148
-
149
- listings = re.findall(
150
- r'<li class="cl-static-search-result" title="([^"]+)"[^>]*>\s*'
151
- r'<a href="([^"]+)"[^>]*>.*?'
152
- r'<div class="price">([^<]*)</div>.*?'
153
- r'<div class="location">\s*([^<]*?)\s*</div>',
154
- html, re.DOTALL
155
- )
156
-
157
- results = []
158
- for title, url, price, location in listings:
159
- pid_match = re.search(r'/(\d+)\.html$', url)
160
- results.append({
161
- "post_id": pid_match.group(1) if pid_match else None,
162
- "title": title,
163
- "url": url,
164
- "price": price.strip() or None, # None if listing has no price
165
- "location": location.strip(),
166
- })
167
- return results
168
-
169
- # Usage
170
- results = search_craigslist("sfbay", "sss", "macbook pro", max_price=1000)
171
- for r in results[:5]:
172
- print(r["post_id"], r["price"], r["location"], r["title"][:50])
173
- ```
174
-
175
- ### Handling missing price
176
-
177
- Listings without a price have no `<div class="price">` element. The regex above returns an empty string
178
- for `price`; the example converts that to `None`. A more robust extraction:
179
-
180
- ```python
181
- def parse_listings(html):
182
- results = []
183
- for block in re.findall(r'<li class="cl-static-search-result"(.*?)</li>', html, re.DOTALL):
184
- title = re.search(r'title="([^"]+)"', block)
185
- url = re.search(r'href="([^"]+)"', block)
186
- price = re.search(r'<div class="price">([^<]+)</div>', block)
187
- loc = re.search(r'<div class="location">\s*([^<]*?)\s*</div>', block)
188
- if not url: continue
189
- url_str = url.group(1)
190
- pid = re.search(r'/(\d+)\.html$', url_str)
191
- results.append({
192
- "post_id": pid.group(1) if pid else None,
193
- "title": title.group(1) if title else None,
194
- "url": url_str,
195
- "price": price.group(1).strip() if price else None,
196
- "location": loc.group(1).strip() if loc else None,
197
- })
198
- return results
199
- ```
200
-
201
- ## Individual listing page extraction
202
-
203
- Listing pages are also fully server-rendered. All fields are present in the raw HTML.
204
-
205
- ```python
206
- def get_listing(url):
207
- headers = {"User-Agent": "Mozilla/5.0"}
208
- html = http_get(url, headers=headers)
209
-
210
- title = re.search(r'<span id="titletextonly">([^<]+)</span>', html)
211
- price = re.search(r'<span class="price">(\$[\d,]+)</span>', html)
212
- # Location is in parentheses right after the price span
213
- location = re.search(
214
- r'<span class="price">[^<]+</span><span>\s*\(([^)]+)\)\s*</span>', html
215
- )
216
- posted = re.search(r'class="date timeago"[^>]+datetime="([^"]+)"', html)
217
- post_id = re.search(r'post id:\s*(\d+)', html)
218
-
219
- # Description body
220
- body_block = re.search(r'section id="postingbody"[^>]*>(.*?)</section>', html, re.DOTALL)
221
- body_text = ""
222
- if body_block:
223
- raw = re.sub(r'<[^>]+>', '', body_block.group(1)).strip()
224
- # Remove the "QR Code Link to This Post" print-only block
225
- body_text = re.sub(r'QR Code Link to This Post\s*', '', raw).strip()
226
- body_text = re.sub(r'\s+', ' ', body_text)
227
-
228
- # Images
229
- images = re.findall(r'https://images\.craigslist\.org/[^\s"\']+_600x450\.jpg', html)
230
-
231
- # Attributes (condition, make, model, etc.)
232
- attrs = {}
233
- for labl, valu in re.findall(
234
- r'<span class="labl">([^<]+)</span>.*?<span class="valu">\s*(?:<[^>]+>\s*)*([^<\n]+?)(?:\s*</|\s*<a)',
235
- html, re.DOTALL
236
- ):
237
- attrs[labl.strip().rstrip(':')] = valu.strip()
238
-
239
- return {
240
- "post_id": post_id.group(1) if post_id else None,
241
- "title": title.group(1) if title else None,
242
- "price": price.group(1) if price else None,
243
- "location": location.group(1) if location else None,
244
- "posted": posted.group(1) if posted else None, # ISO 8601 with TZ
245
- "body": body_text,
246
- "images": images,
247
- "attrs": attrs,
248
- }
249
- ```
250
-
251
- ### Sample output — for-sale listing
252
- ```python
253
- {
254
- "post_id": "7917381408",
255
- "title": "Brand new iphone 15 case and screen protector",
256
- "price": "$6",
257
- "location": "cupertino",
258
- "posted": "2026-02-24T16:08:38-0800",
259
- "body": "I bought a new phone. These are brand new! Plz lmk if you are interested.",
260
- "images": ["https://images.craigslist.org/00e0e_xxx_600x450.jpg"],
261
- "attrs": {"condition": "like new", "make / manufacturer": "Apple", "model name / number": "iPhone 15 Plus"},
262
- }
263
- ```
264
-
265
- ### Housing-specific fields
266
-
267
- Housing listings have `<span class="attr important">` blocks for bedrooms/bathrooms and square footage,
268
- separate from the `<div class="attr">` attribute grid:
269
-
270
- ```python
271
- # BR/BA
272
- br_ba = re.search(r'(\d+)BR\s*/\s*(\d+(?:\.\d+)?)Ba', html)
273
- # Square footage
274
- sqft = re.search(r'(\d+)ft<sup>2</sup>', html)
275
-
276
- if br_ba: bedrooms, bathrooms = br_ba.groups()
277
- if sqft: sqft_val = sqft.group(1)
278
- ```
279
-
280
- ## JSON-LD structured data (alternative extraction path)
281
-
282
- Each search page includes an `ItemList` JSON-LD block with up to 330 items. Useful when you want
283
- structured data (price as float, geo coordinates) without regex parsing of HTML:
284
-
285
- ```python
286
- import json, re
287
- from helpers import http_get
288
-
289
- html = http_get("https://sfbay.craigslist.org/search/sss?query=laptop", headers={"User-Agent": "Mozilla/5.0"})
290
- ld_blocks = re.findall(r'<script type="application/ld\+json"[^>]*>(.*?)</script>', html, re.DOTALL)
291
-
292
- for raw in ld_blocks:
293
- data = json.loads(raw)
294
- if data.get('@type') == 'ItemList':
295
- for item in data['itemListElement']:
296
- listing = item['item']
297
- print(
298
- listing.get('name'),
299
- listing.get('offers', {}).get('price'),
300
- listing.get('offers', {}).get('priceCurrency'),
301
- listing.get('offers', {}).get('availableAtOrFrom', {}).get('address', {}).get('addressLocality'),
302
- )
303
- ```
304
-
305
- JSON-LD item fields available: `name`, `description`, `image` (list of URLs),
306
- `offers.price` (float string e.g. `"900.00"`), `offers.priceCurrency`, `offers.availableAtOrFrom.address`,
307
- `offers.availableAtOrFrom.geo.latitude`, `offers.availableAtOrFrom.geo.longitude`.
308
-
309
- Note: JSON-LD items do not include the listing URL or post ID — use the HTML parser for those.
310
- Combine both: use JSON-LD for price/geo, HTML for URL/post ID.
311
-
312
- ## Pagination behavior
313
-
314
- The `s=` offset parameter in the URL is only respected by the JS-driven XHR layer in a real browser.
315
- When accessed via `http_get`, the static HTML fallback renders all results regardless of `s=`:
316
-
317
- ```
318
- s=0 → same 342 listings
319
- s=120 → same 342 listings (confirmed identical URL sets)
320
- s=300 → same 342 listings
321
- ```
322
-
323
- **Recommendation**: Do not attempt pagination via `http_get`. Use search filters to narrow results:
324
-
325
- ```python
326
- # Instead of paginating, narrow by price range
327
- under_500 = search_craigslist("sfbay", "sss", "macbook", max_price=500)
328
- over_500 = search_craigslist("sfbay", "sss", "macbook", min_price=501)
329
- ```
330
-
331
- If true pagination is required (e.g. you need more than 350 results), you must use a browser session
332
- with `goto_url()` + `wait_for_load()`.
333
-
334
- ## Bot detection
335
-
336
- None observed. Craigslist does not block `http_get` requests. During testing:
337
- - All 6+ test cities returned full HTML (HTML size 174K–530K bytes per page)
338
- - No CAPTCHA page, no redirect to `robot-check`, no `403`
339
- - No cookie or session required
340
- - Works with minimal `User-Agent` header: `"Mozilla/5.0"` is sufficient
341
-
342
- Defensive check (in case behavior changes):
343
-
344
- ```python
345
- def is_blocked(html):
346
- return (
347
- len(html) < 5000 or
348
- "blocked" in html[:2000].lower() or
349
- "captcha" in html[:2000].lower() or
350
- "cl-static-search-result" not in html
351
- )
352
- ```
353
-
354
- ## Gotchas
355
-
356
- - **`data-pid` does not exist in static HTML**: Old Craigslist used `data-pid` attributes. The current
357
- static renderer uses `<li class="cl-static-search-result">` with title attribute and embedded `<a href>`.
358
- Do not search for `data-pid`, `result-row`, or `cl-search-result` — they are absent.
359
-
360
- - **Post ID comes from the URL, not an attribute**: Extract it as the numeric segment before `.html`
361
- in the listing URL: `re.search(r'/(\d+)\.html$', url).group(1)`.
362
-
363
- - **Price may be absent**: Free listings and "contact for price" listings have no `<div class="price">`.
364
- The regex returns an empty string; convert to `None`.
365
-
366
- - **`s=` pagination is a no-op in static HTML**: The fallback renderer always returns the full result set.
367
- Don't loop over pages — filter instead.
368
-
369
- - **HTML entities in titles**: Titles may contain `&amp;`, `&quot;`, etc. Use
370
- `html.unescape(title)` from the standard library if you need clean text.
371
-
372
- - **URL structure varies by area**: The area code in the URL (`/sby/`, `/sfc/`, `/eby/`) is the sub-area
373
- of the city (e.g. South Bay, San Francisco, East Bay). It is part of the listing URL but not needed
374
- for constructing search URLs (which use the city subdomain only).
375
-
376
- - **`<li class="cl-static-hub-links">` is not a listing**: The first `<li>` in the results `<ol>` is
377
- a "see also" block. The regex patterns above skip it automatically because it has no `title` attribute.
378
-
379
- - **JSON-LD count < HTML count**: JSON-LD block may contain ~330 items while the HTML block shows ~350.
380
- The HTML parser is authoritative; JSON-LD is a secondary data source.
381
-
382
- - **Body text contains print-only junk**: The `<section id="postingbody">` starts with a
383
- "QR Code Link to This Post" print-only element. Strip it with a simple string replacement
384
- (shown in the extractor above).
385
-
386
- - **HTML-escaped body text**: Description bodies may contain `&amp;`, `&lt;`, etc. Unescape if needed:
387
- ```python
388
- import html as html_lib
389
- body_clean = html_lib.unescape(body_text)
390
- ```
1
+ # Craigslist — Scraping via http_get
2
+
3
+ Field-tested against sfbay.craigslist.org and multiple city subdomains on 2026-04-18.
4
+ `http_get` works without any bot detection — no CAPTCHA, no block, no rate limit observed.
5
+ Craigslist serves a full server-rendered HTML fallback (the `<ol class="cl-static-search-results">` block)
6
+ intended for no-JS browsers. This fallback contains **all matching results in one response** (300–360
7
+ items typical), regardless of the `s=` offset parameter. No browser needed.
8
+
9
+ ## Key discovery: static HTML returns everything at once
10
+
11
+ When you `http_get` a Craigslist search URL, the server includes a `<ol class="cl-static-search-results">`
12
+ block that contains every matching listing (up to ~360) in a single HTML response. The `s=` pagination
13
+ parameter is ignored by the static renderer — it is only meaningful for the JS-driven XHR path used by
14
+ real browsers. For scraping purposes, this means:
15
+
16
+ - One `http_get` call per search query returns the full result set (no pagination loop needed).
17
+ - For broader searches, narrow via `query=`, `min_price=`, `max_price=`, and category code in the URL.
18
+ - If you need more than ~360 results, you must use a headless browser with JS. For most tasks,
19
+ one request is sufficient.
20
+
21
+ ## URL patterns
22
+
23
+ ### City subdomains
24
+ ```
25
+ https://{city}.craigslist.org/search/{category_code}?query=...
26
+ ```
27
+
28
+ Confirmed working cities (exact subdomain names):
29
+
30
+ | City | Subdomain |
31
+ |----------------|------------------|
32
+ | SF Bay Area | `sfbay` |
33
+ | New York | `newyork` |
34
+ | Chicago | `chicago` |
35
+ | Los Angeles | `losangeles` |
36
+ | Seattle | `seattle` |
37
+ | Boston | `boston` |
38
+ | Miami | `miami` |
39
+ | Denver | `denver` |
40
+ | Austin | `austin` |
41
+ | Portland | `portland` |
42
+ | San Diego | `sandiego` |
43
+ | Phoenix | `phoenix` |
44
+
45
+ ### Category codes (confirmed working)
46
+
47
+ | Code | Category |
48
+ |-------|---------------------------|
49
+ | `sss` | For Sale — all |
50
+ | `for` | For Sale — general |
51
+ | `ela` | Electronics (listings) |
52
+ | `ele` | Electronics (search) |
53
+ | `fua` | Furniture |
54
+ | `clo` | Clothing & accessories |
55
+ | `spo` | Sporting goods |
56
+ | `toy` | Toys & games |
57
+ | `cto` | Cars+trucks — by owner |
58
+ | `cta` | Cars+trucks — by dealer |
59
+ | `hhh` | Housing — all |
60
+ | `apa` | Apartments |
61
+ | `roo` | Rooms & shares |
62
+ | `sub` | Sublets & temporary |
63
+ | `jjj` | Jobs — all |
64
+ | `sof` | Software/QA/DBA jobs |
65
+ | `bbb` | Services — all |
66
+ | `ggg` | Gigs — all |
67
+ | `com` | Community |
68
+ | `eve` | Events |
69
+ | `vol` | Volunteers |
70
+
71
+ ### Query parameters
72
+
73
+ | Parameter | Effect |
74
+ |---------------|------------------------------------------------|
75
+ | `query=` | Keyword search |
76
+ | `sort=rel` | Sort by relevance (default) |
77
+ | `sort=date` | Sort by newest first |
78
+ | `sort=priceasc` | Price low to high |
79
+ | `sort=pricedsc` | Price high to low |
80
+ | `min_price=` | Minimum price filter |
81
+ | `max_price=` | Maximum price filter |
82
+ | `condition=10` | New (for-sale listings) |
83
+ | `condition=20` | Like new |
84
+ | `condition=30` | Excellent |
85
+ | `condition=40` | Good |
86
+ | `condition=50` | Fair |
87
+ | `condition=60` | Salvage |
88
+ | `bedrooms=` | Number of bedrooms (housing only) |
89
+ | `auto_make_model=` | Car make/model filter (cars category) |
90
+ | `s=` | Pagination offset — **ignored in static HTML** |
91
+
92
+ ### Example URLs
93
+ ```python
94
+ # For-sale keyword search
95
+ "https://sfbay.craigslist.org/search/sss?query=macbook&sort=rel"
96
+
97
+ # Price-filtered electronics
98
+ "https://sfbay.craigslist.org/search/ela?query=iphone&min_price=100&max_price=500"
99
+
100
+ # Apartments, 2 bedrooms, price range
101
+ "https://sfbay.craigslist.org/search/apa?bedrooms=2&min_price=1000&max_price=2500"
102
+
103
+ # Cars by owner, Toyota
104
+ "https://sfbay.craigslist.org/search/cto?auto_make_model=toyota"
105
+
106
+ # Jobs in another city
107
+ "https://chicago.craigslist.org/search/jjj?query=python+developer"
108
+ ```
109
+
110
+ ## Listing card HTML structure
111
+
112
+ Each listing is an `<li class="cl-static-search-result">` inside `<ol class="cl-static-search-results">`.
113
+
114
+ ```html
115
+ <li class="cl-static-search-result" title="MacBook Air M2 256GB 8GB RAM">
116
+ <a href="https://sfbay.craigslist.org/sby/ele/d/san-jose-macbook-air-m2/7928508295.html">
117
+ <div class="title">MacBook Air M2 256GB 8GB RAM</div>
118
+ <div class="details">
119
+ <div class="price">$900</div>
120
+ <div class="location">San Jose</div>
121
+ </div>
122
+ </a>
123
+ </li>
124
+ ```
125
+
126
+ Fields available in the listing card:
127
+ - **Title**: `title` attribute on `<li>` OR text inside `<div class="title">`
128
+ - **URL**: `href` on the `<a>` tag — always a full absolute URL
129
+ - **Price**: `<div class="price">` — may be absent on free/contact-for-price listings
130
+ - **Location/neighborhood**: `<div class="location">` — neighborhood name or city
131
+ - **Post ID**: last segment of the URL before `.html` (e.g. `/7928508295.html` → `7928508295`)
132
+
133
+ URL pattern: `https://{city}.craigslist.org/{area}/{category_code}/d/{slug}/{post_id}.html`
134
+
135
+ ## Parsing search results (field-tested)
136
+
137
+ ```python
138
+ import re
139
+ from helpers import http_get
140
+
141
+ def search_craigslist(city, category, query, min_price=None, max_price=None):
142
+ params = f"query={query.replace(' ', '+')}&sort=rel"
143
+ if min_price: params += f"&min_price={min_price}"
144
+ if max_price: params += f"&max_price={max_price}"
145
+ url = f"https://{city}.craigslist.org/search/{category}?{params}"
146
+ headers = {"User-Agent": "Mozilla/5.0"}
147
+ html = http_get(url, headers=headers)
148
+
149
+ listings = re.findall(
150
+ r'<li class="cl-static-search-result" title="([^"]+)"[^>]*>\s*'
151
+ r'<a href="([^"]+)"[^>]*>.*?'
152
+ r'<div class="price">([^<]*)</div>.*?'
153
+ r'<div class="location">\s*([^<]*?)\s*</div>',
154
+ html, re.DOTALL
155
+ )
156
+
157
+ results = []
158
+ for title, url, price, location in listings:
159
+ pid_match = re.search(r'/(\d+)\.html$', url)
160
+ results.append({
161
+ "post_id": pid_match.group(1) if pid_match else None,
162
+ "title": title,
163
+ "url": url,
164
+ "price": price.strip() or None, # None if listing has no price
165
+ "location": location.strip(),
166
+ })
167
+ return results
168
+
169
+ # Usage
170
+ results = search_craigslist("sfbay", "sss", "macbook pro", max_price=1000)
171
+ for r in results[:5]:
172
+ print(r["post_id"], r["price"], r["location"], r["title"][:50])
173
+ ```
174
+
175
+ ### Handling missing price
176
+
177
+ Listings without a price have no `<div class="price">` element. The regex above returns an empty string
178
+ for `price`; the example converts that to `None`. A more robust extraction:
179
+
180
+ ```python
181
+ def parse_listings(html):
182
+ results = []
183
+ for block in re.findall(r'<li class="cl-static-search-result"(.*?)</li>', html, re.DOTALL):
184
+ title = re.search(r'title="([^"]+)"', block)
185
+ url = re.search(r'href="([^"]+)"', block)
186
+ price = re.search(r'<div class="price">([^<]+)</div>', block)
187
+ loc = re.search(r'<div class="location">\s*([^<]*?)\s*</div>', block)
188
+ if not url: continue
189
+ url_str = url.group(1)
190
+ pid = re.search(r'/(\d+)\.html$', url_str)
191
+ results.append({
192
+ "post_id": pid.group(1) if pid else None,
193
+ "title": title.group(1) if title else None,
194
+ "url": url_str,
195
+ "price": price.group(1).strip() if price else None,
196
+ "location": loc.group(1).strip() if loc else None,
197
+ })
198
+ return results
199
+ ```
200
+
201
+ ## Individual listing page extraction
202
+
203
+ Listing pages are also fully server-rendered. All fields are present in the raw HTML.
204
+
205
+ ```python
206
+ def get_listing(url):
207
+ headers = {"User-Agent": "Mozilla/5.0"}
208
+ html = http_get(url, headers=headers)
209
+
210
+ title = re.search(r'<span id="titletextonly">([^<]+)</span>', html)
211
+ price = re.search(r'<span class="price">(\$[\d,]+)</span>', html)
212
+ # Location is in parentheses right after the price span
213
+ location = re.search(
214
+ r'<span class="price">[^<]+</span><span>\s*\(([^)]+)\)\s*</span>', html
215
+ )
216
+ posted = re.search(r'class="date timeago"[^>]+datetime="([^"]+)"', html)
217
+ post_id = re.search(r'post id:\s*(\d+)', html)
218
+
219
+ # Description body
220
+ body_block = re.search(r'section id="postingbody"[^>]*>(.*?)</section>', html, re.DOTALL)
221
+ body_text = ""
222
+ if body_block:
223
+ raw = re.sub(r'<[^>]+>', '', body_block.group(1)).strip()
224
+ # Remove the "QR Code Link to This Post" print-only block
225
+ body_text = re.sub(r'QR Code Link to This Post\s*', '', raw).strip()
226
+ body_text = re.sub(r'\s+', ' ', body_text)
227
+
228
+ # Images
229
+ images = re.findall(r'https://images\.craigslist\.org/[^\s"\']+_600x450\.jpg', html)
230
+
231
+ # Attributes (condition, make, model, etc.)
232
+ attrs = {}
233
+ for labl, valu in re.findall(
234
+ r'<span class="labl">([^<]+)</span>.*?<span class="valu">\s*(?:<[^>]+>\s*)*([^<\n]+?)(?:\s*</|\s*<a)',
235
+ html, re.DOTALL
236
+ ):
237
+ attrs[labl.strip().rstrip(':')] = valu.strip()
238
+
239
+ return {
240
+ "post_id": post_id.group(1) if post_id else None,
241
+ "title": title.group(1) if title else None,
242
+ "price": price.group(1) if price else None,
243
+ "location": location.group(1) if location else None,
244
+ "posted": posted.group(1) if posted else None, # ISO 8601 with TZ
245
+ "body": body_text,
246
+ "images": images,
247
+ "attrs": attrs,
248
+ }
249
+ ```
250
+
251
+ ### Sample output — for-sale listing
252
+ ```python
253
+ {
254
+ "post_id": "7917381408",
255
+ "title": "Brand new iphone 15 case and screen protector",
256
+ "price": "$6",
257
+ "location": "cupertino",
258
+ "posted": "2026-02-24T16:08:38-0800",
259
+ "body": "I bought a new phone. These are brand new! Plz lmk if you are interested.",
260
+ "images": ["https://images.craigslist.org/00e0e_xxx_600x450.jpg"],
261
+ "attrs": {"condition": "like new", "make / manufacturer": "Apple", "model name / number": "iPhone 15 Plus"},
262
+ }
263
+ ```
264
+
265
+ ### Housing-specific fields
266
+
267
+ Housing listings have `<span class="attr important">` blocks for bedrooms/bathrooms and square footage,
268
+ separate from the `<div class="attr">` attribute grid:
269
+
270
+ ```python
271
+ # BR/BA
272
+ br_ba = re.search(r'(\d+)BR\s*/\s*(\d+(?:\.\d+)?)Ba', html)
273
+ # Square footage
274
+ sqft = re.search(r'(\d+)ft<sup>2</sup>', html)
275
+
276
+ if br_ba: bedrooms, bathrooms = br_ba.groups()
277
+ if sqft: sqft_val = sqft.group(1)
278
+ ```
279
+
280
+ ## JSON-LD structured data (alternative extraction path)
281
+
282
+ Each search page includes an `ItemList` JSON-LD block with up to 330 items. Useful when you want
283
+ structured data (price as float, geo coordinates) without regex parsing of HTML:
284
+
285
+ ```python
286
+ import json, re
287
+ from helpers import http_get
288
+
289
+ html = http_get("https://sfbay.craigslist.org/search/sss?query=laptop", headers={"User-Agent": "Mozilla/5.0"})
290
+ ld_blocks = re.findall(r'<script type="application/ld\+json"[^>]*>(.*?)</script>', html, re.DOTALL)
291
+
292
+ for raw in ld_blocks:
293
+ data = json.loads(raw)
294
+ if data.get('@type') == 'ItemList':
295
+ for item in data['itemListElement']:
296
+ listing = item['item']
297
+ print(
298
+ listing.get('name'),
299
+ listing.get('offers', {}).get('price'),
300
+ listing.get('offers', {}).get('priceCurrency'),
301
+ listing.get('offers', {}).get('availableAtOrFrom', {}).get('address', {}).get('addressLocality'),
302
+ )
303
+ ```
304
+
305
+ JSON-LD item fields available: `name`, `description`, `image` (list of URLs),
306
+ `offers.price` (float string e.g. `"900.00"`), `offers.priceCurrency`, `offers.availableAtOrFrom.address`,
307
+ `offers.availableAtOrFrom.geo.latitude`, `offers.availableAtOrFrom.geo.longitude`.
308
+
309
+ Note: JSON-LD items do not include the listing URL or post ID — use the HTML parser for those.
310
+ Combine both: use JSON-LD for price/geo, HTML for URL/post ID.
311
+
312
+ ## Pagination behavior
313
+
314
+ The `s=` offset parameter in the URL is only respected by the JS-driven XHR layer in a real browser.
315
+ When accessed via `http_get`, the static HTML fallback renders all results regardless of `s=`:
316
+
317
+ ```
318
+ s=0 → same 342 listings
319
+ s=120 → same 342 listings (confirmed identical URL sets)
320
+ s=300 → same 342 listings
321
+ ```
322
+
323
+ **Recommendation**: Do not attempt pagination via `http_get`. Use search filters to narrow results:
324
+
325
+ ```python
326
+ # Instead of paginating, narrow by price range
327
+ under_500 = search_craigslist("sfbay", "sss", "macbook", max_price=500)
328
+ over_500 = search_craigslist("sfbay", "sss", "macbook", min_price=501)
329
+ ```
330
+
331
+ If true pagination is required (e.g. you need more than 350 results), you must use a browser session
332
+ with `goto_url()` + `wait_for_load()`.
333
+
334
+ ## Bot detection
335
+
336
+ None observed. Craigslist does not block `http_get` requests. During testing:
337
+ - All 6+ test cities returned full HTML (HTML size 174K–530K bytes per page)
338
+ - No CAPTCHA page, no redirect to `robot-check`, no `403`
339
+ - No cookie or session required
340
+ - Works with minimal `User-Agent` header: `"Mozilla/5.0"` is sufficient
341
+
342
+ Defensive check (in case behavior changes):
343
+
344
+ ```python
345
+ def is_blocked(html):
346
+ return (
347
+ len(html) < 5000 or
348
+ "blocked" in html[:2000].lower() or
349
+ "captcha" in html[:2000].lower() or
350
+ "cl-static-search-result" not in html
351
+ )
352
+ ```
353
+
354
+ ## Gotchas
355
+
356
+ - **`data-pid` does not exist in static HTML**: Old Craigslist used `data-pid` attributes. The current
357
+ static renderer uses `<li class="cl-static-search-result">` with title attribute and embedded `<a href>`.
358
+ Do not search for `data-pid`, `result-row`, or `cl-search-result` — they are absent.
359
+
360
+ - **Post ID comes from the URL, not an attribute**: Extract it as the numeric segment before `.html`
361
+ in the listing URL: `re.search(r'/(\d+)\.html$', url).group(1)`.
362
+
363
+ - **Price may be absent**: Free listings and "contact for price" listings have no `<div class="price">`.
364
+ The regex returns an empty string; convert to `None`.
365
+
366
+ - **`s=` pagination is a no-op in static HTML**: The fallback renderer always returns the full result set.
367
+ Don't loop over pages — filter instead.
368
+
369
+ - **HTML entities in titles**: Titles may contain `&amp;`, `&quot;`, etc. Use
370
+ `html.unescape(title)` from the standard library if you need clean text.
371
+
372
+ - **URL structure varies by area**: The area code in the URL (`/sby/`, `/sfc/`, `/eby/`) is the sub-area
373
+ of the city (e.g. South Bay, San Francisco, East Bay). It is part of the listing URL but not needed
374
+ for constructing search URLs (which use the city subdomain only).
375
+
376
+ - **`<li class="cl-static-hub-links">` is not a listing**: The first `<li>` in the results `<ol>` is
377
+ a "see also" block. The regex patterns above skip it automatically because it has no `title` attribute.
378
+
379
+ - **JSON-LD count < HTML count**: JSON-LD block may contain ~330 items while the HTML block shows ~350.
380
+ The HTML parser is authoritative; JSON-LD is a secondary data source.
381
+
382
+ - **Body text contains print-only junk**: The `<section id="postingbody">` starts with a
383
+ "QR Code Link to This Post" print-only element. Strip it with a simple string replacement
384
+ (shown in the extractor above).
385
+
386
+ - **HTML-escaped body text**: Description bodies may contain `&amp;`, `&lt;`, etc. Unescape if needed:
387
+ ```python
388
+ import html as html_lib
389
+ body_clean = html_lib.unescape(body_text)
390
+ ```