@pencil-agent/nano-pencil 2.0.1 → 2.0.2

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 (186) 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/model/custom-providers.js +1 -1
  7. package/dist/core/model-registry.js +5 -5
  8. package/dist/extensions/builtin/AGENT.md +115 -115
  9. package/dist/extensions/builtin/browser/AGENT.md +17 -17
  10. package/dist/extensions/builtin/browser/agent-workspace/agent_helpers.py +12 -12
  11. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/amazon/product-search.md +198 -198
  12. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/archive-org/scraping.md +341 -341
  13. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv/scraping.md +311 -311
  14. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/arxiv-bulk/scraping.md +333 -333
  15. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/atlas/overview.md +70 -70
  16. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/booking-com/scraping.md +578 -578
  17. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/capterra/scraping.md +440 -440
  18. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/centilebrain/generate-estimates.md +110 -110
  19. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coingecko/scraping.md +325 -325
  20. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coinmarketcap/scraping.md +463 -463
  21. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/coursera/scraping.md +360 -360
  22. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/craigslist/scraping.md +390 -390
  23. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/crossref/scraping.md +568 -568
  24. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/dev-to/scraping.md +323 -323
  25. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/duckduckgo/scraping.md +349 -349
  26. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/ebay/scraping.md +435 -435
  27. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/etsy/scraping.md +506 -506
  28. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/eventbrite/scraping.md +363 -363
  29. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/expedia/automation.md +168 -168
  30. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/groups.md +236 -236
  31. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/facebook/pages.md +295 -295
  32. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/framer/editor.md +108 -108
  33. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/fred/scraping.md +493 -493
  34. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/g2/scraping.md +580 -580
  35. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/genius/scraping.md +511 -511
  36. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/repo-actions.md +65 -65
  37. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/github/scraping.md +184 -184
  38. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/glassdoor/scraping.md +543 -543
  39. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gmail/compose.md +122 -122
  40. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/goodreads/scraping.md +461 -461
  41. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/gutenberg/scraping.md +383 -383
  42. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/hackernews/scraping.md +243 -243
  43. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/howlongtobeat/scraping.md +473 -473
  44. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/imdb/scraping.md +271 -271
  45. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/itch-io/scraping.md +436 -436
  46. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/job-boards/indeed-glassdoor.md +1021 -1021
  47. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/letterboxd/scraping.md +349 -349
  48. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/linkedin/invitation-manager.md +109 -109
  49. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/loom/folder-enumeration.md +170 -170
  50. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/macrotrends/scraping.md +537 -537
  51. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/article-hydration.md +120 -120
  52. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/medium/scraping.md +414 -414
  53. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/metacritic/scraping.md +477 -477
  54. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/musicbrainz/scraping.md +478 -478
  55. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/nasa/scraping.md +339 -339
  56. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/news-aggregation/multi-source.md +205 -205
  57. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/open-library/scraping.md +472 -472
  58. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openalex/scraping.md +470 -470
  59. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/openstreetmap/scraping.md +490 -490
  60. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/package-registries/npm-pypi.md +478 -478
  61. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/polymarket/scraping.md +234 -234
  62. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/producthunt/scraping.md +307 -307
  63. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/pubmed/scraping.md +421 -421
  64. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/quora/scraping.md +364 -364
  65. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rawg/scraping.md +352 -352
  66. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/reddit/scraping.md +124 -124
  67. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/rest-countries/scraping.md +233 -233
  68. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/sec-edgar/scraping.md +361 -361
  69. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/README.md +36 -36
  70. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/embedded-apps.md +72 -72
  71. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/knowledge-base.md +109 -109
  72. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/shopify-admin/polaris-inputs.md +137 -137
  73. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/soundcloud/scraping.md +362 -362
  74. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/spotify/scraping.md +339 -339
  75. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/stackoverflow/scraping.md +435 -435
  76. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/steam/scraping.md +575 -575
  77. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/substack/scraping.md +338 -338
  78. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/thetechgeeks/pricing.md +52 -52
  79. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tiktok/upload.md +107 -107
  80. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/tradingview/scraping.md +309 -309
  81. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trello/boards-and-lists.md +88 -88
  82. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/trustpilot/scraping.md +375 -375
  83. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/walmart/scraping.md +444 -444
  84. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wayback-machine/scraping.md +306 -306
  85. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/weather/scraping.md +398 -398
  86. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/wellfound/scraping.md +596 -596
  87. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/world-bank/scraping.md +356 -356
  88. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/xiaohongshu/scraping.md +84 -84
  89. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/youtube/scraping.md +418 -418
  90. package/dist/extensions/builtin/browser/agent-workspace/domain-skills/zillow/scraping.md +433 -433
  91. package/dist/extensions/builtin/browser/browser.md +73 -73
  92. package/dist/extensions/builtin/browser/install.md +142 -142
  93. package/dist/extensions/builtin/browser/interaction-skills/connection.md +48 -48
  94. package/dist/extensions/builtin/browser/interaction-skills/cookies.md +3 -3
  95. package/dist/extensions/builtin/browser/interaction-skills/cross-origin-iframes.md +3 -3
  96. package/dist/extensions/builtin/browser/interaction-skills/dialogs.md +64 -64
  97. package/dist/extensions/builtin/browser/interaction-skills/downloads.md +3 -3
  98. package/dist/extensions/builtin/browser/interaction-skills/drag-and-drop.md +3 -3
  99. package/dist/extensions/builtin/browser/interaction-skills/dropdowns.md +3 -3
  100. package/dist/extensions/builtin/browser/interaction-skills/iframes.md +3 -3
  101. package/dist/extensions/builtin/browser/interaction-skills/network-requests.md +3 -3
  102. package/dist/extensions/builtin/browser/interaction-skills/print-as-pdf.md +3 -3
  103. package/dist/extensions/builtin/browser/interaction-skills/profile-sync.md +90 -90
  104. package/dist/extensions/builtin/browser/interaction-skills/screenshots.md +17 -17
  105. package/dist/extensions/builtin/browser/interaction-skills/scrolling.md +3 -3
  106. package/dist/extensions/builtin/browser/interaction-skills/shadow-dom.md +3 -3
  107. package/dist/extensions/builtin/browser/interaction-skills/tabs.md +69 -69
  108. package/dist/extensions/builtin/browser/interaction-skills/uploads.md +1 -1
  109. package/dist/extensions/builtin/browser/interaction-skills/viewport.md +3 -3
  110. package/dist/extensions/builtin/browser/src/browser_harness/AGENT.md +15 -15
  111. package/dist/extensions/builtin/browser/src/browser_harness/__init__.py +8 -8
  112. package/dist/extensions/builtin/browser/src/browser_harness/_ipc.py +90 -90
  113. package/dist/extensions/builtin/browser/src/browser_harness/admin.py +722 -722
  114. package/dist/extensions/builtin/browser/src/browser_harness/daemon.py +328 -328
  115. package/dist/extensions/builtin/browser/src/browser_harness/helpers.py +396 -396
  116. package/dist/extensions/builtin/browser/src/browser_harness/run.py +103 -103
  117. package/dist/extensions/builtin/discipline/skills/brainstorming/SKILL.md +33 -33
  118. package/dist/extensions/builtin/discipline/skills/executing-plans/SKILL.md +25 -25
  119. package/dist/extensions/builtin/discipline/skills/finishing-development-branch/SKILL.md +25 -25
  120. package/dist/extensions/builtin/discipline/skills/receiving-code-review/SKILL.md +22 -22
  121. package/dist/extensions/builtin/discipline/skills/requesting-code-review/SKILL.md +31 -31
  122. package/dist/extensions/builtin/discipline/skills/systematic-debugging/SKILL.md +28 -28
  123. package/dist/extensions/builtin/discipline/skills/test-driven-development/SKILL.md +32 -32
  124. package/dist/extensions/builtin/discipline/skills/using-git-worktrees/SKILL.md +25 -25
  125. package/dist/extensions/builtin/discipline/skills/verification-before-completion/SKILL.md +27 -27
  126. package/dist/extensions/builtin/discipline/skills/writing-plans/SKILL.md +26 -26
  127. package/dist/extensions/builtin/goal/README.md +67 -67
  128. package/dist/extensions/builtin/grub/README.md +112 -112
  129. package/dist/extensions/builtin/link-world/agent-workspace/README.md +16 -16
  130. package/dist/extensions/builtin/link-world/internet-search/internet-search.md +65 -65
  131. package/dist/extensions/builtin/link-world/link-world-agent.md +82 -82
  132. package/dist/extensions/builtin/link-world/linkworld.md +313 -313
  133. package/dist/extensions/builtin/link-world/network-routing/network-routing.md +67 -67
  134. package/dist/extensions/builtin/loop/README.md +92 -92
  135. package/dist/extensions/builtin/mcp/figma-design.md +68 -68
  136. package/dist/extensions/builtin/mcp/mcp-management.md +85 -85
  137. package/dist/extensions/builtin/recap/AGENT.md +15 -15
  138. package/dist/extensions/builtin/sal/README.md +72 -72
  139. package/dist/extensions/builtin/security-audit/README.md +289 -289
  140. package/dist/extensions/builtin/team/AGENT.md +112 -112
  141. package/dist/extensions/builtin/team/TESTING.md +299 -299
  142. package/dist/extensions/builtin/token-save/README.md +56 -56
  143. package/dist/extensions/optional/AGENT.md +10 -10
  144. package/dist/modes/interactive/controllers/input-submit-controller.js +2 -2
  145. package/dist/modes/interactive/controllers/stream-render-controller.js +2 -2
  146. package/dist/modes/interactive/interactive-mode.js +19 -19
  147. package/dist/modes/interactive/theme/dark.json +85 -85
  148. package/dist/modes/interactive/theme/light.json +84 -84
  149. package/dist/modes/interactive/theme/theme-schema.json +335 -335
  150. package/dist/modes/interactive/theme/warm.json +81 -81
  151. package/dist/node_modules/@pencil-agent/ai/dist/cli.js +0 -0
  152. package/dist/node_modules/@pencil-agent/ai/dist/models.generated.js +1 -1
  153. 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 +851 -0
  154. package/docs/SDK-TESTING.md +364 -0
  155. package/docs/codex-goal-command-impl.md +1055 -1055
  156. package/docs/codex-goal-vs-grub.md +500 -500
  157. package/docs/custom-provider.md +27 -27
  158. package/docs/extensions.md +27 -27
  159. package/docs/keybindings.md +27 -27
  160. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/200/273/347/273/223.md" +250 -250
  161. package/docs/loop /351/207/215/346/236/204/345/256/214/346/210/220/346/212/245/345/221/212.md" +122 -122
  162. package/docs/loop /351/207/215/346/236/204/346/226/271/346/241/210.md" +1222 -1222
  163. 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
  164. 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
  165. package/docs/loop /351/207/215/346/236/204/350/256/241/345/210/222.md" +320 -320
  166. package/docs/loop-usage-examples.md +214 -214
  167. package/docs/mem-core/346/212/200/346/234/257/346/226/207/346/241/243.md +593 -0
  168. package/docs/models.md +27 -27
  169. package/docs/packages.md +27 -27
  170. package/docs/pi-design-philosophy.md +457 -457
  171. package/docs/planmode.md +1987 -1987
  172. package/docs/prompt-templates.md +27 -27
  173. package/docs/providers.md +27 -27
  174. package/docs/sdk.md +27 -27
  175. package/docs/skills.md +27 -27
  176. package/docs/startup-performance-optimization.md +301 -0
  177. package/docs/themes.md +27 -27
  178. package/docs/tui.md +27 -27
  179. package/docs//350/256/244/347/237/245/345/234/260/345/233/276.md +47 -0
  180. package/package.json +190 -190
  181. package/docs/cc-agent-design.md +0 -1297
  182. package/docs/cc-tui-design.md +0 -1333
  183. package/docs/nanoPencil-/345/255/246/344/271/240/350/256/241/345/210/222.md +0 -170
  184. package/docs/scan-report.md +0 -3820
  185. package/docs//345/257/271/346/240/207Claude-Code.md +0 -1775
  186. 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 +0 -261
@@ -1,580 +1,580 @@
1
- # G2 — B2B Software Reviews
2
-
3
- Field-tested against g2.com on 2026-04-18.
4
-
5
- ## Anti-bot verdict: browser required — DataDome blocks every http_get request
6
-
7
- `http_get` returns HTTP 403 on every g2.com URL without exception.
8
-
9
- Tested URLs (all 403):
10
- - `https://www.g2.com/products/slack/reviews`
11
- - `https://www.g2.com/categories/team-collaboration`
12
- - `https://www.g2.com/products/slack`
13
- - `https://www.g2.com/products/slack/reviews.json`
14
- - `https://www.g2.com/blog/` (and most `www.g2.com/*`)
15
-
16
- UAs tested (all blocked): `Mozilla/5.0`, full Chrome 124 macOS, Googlebot.
17
-
18
- **Stack:**
19
- - **Primary:** DataDome 5.6.1 (`X-DataDome: protected`, `X-DD-B: 1`). Response mode `rt:'c'` = CAPTCHA challenge. Mode `rt:'i'` = invalid/replayed cookie. The `datadome=...` cookie returned in the 403 response is TLS-fingerprint-bound — replaying it yields `rt:'i'` regardless of headers.
20
- - **Secondary:** Cloudflare CDN (`Server: cloudflare`, `CF-RAY` header present).
21
-
22
- DataDome's challenge is **silent** — no CAPTCHA widget appears in a real browser. JS fingerprinting runs post-DOM-ready and resolves automatically. A real Chrome session via CDP passes cleanly.
23
-
24
- Pages **not** behind DataDome (safe to `http_get`): `help.g2.com`, `research.g2.com`, `learn.g2.com`, `data.g2.com/api/docs`.
25
-
26
- **Use `goto_url()` + `wait()` exclusively. Never use `http_get` for www.g2.com.**
27
-
28
- ---
29
-
30
- ## Fastest approach: official vendor API (if you have a key)
31
-
32
- G2 provides a public REST API at `https://data.g2.com/api/v1` documented at `https://data.g2.com/api/docs`. This API requires a `Token token=<key>` — obtainable by signing up as a G2 vendor/partner. If you have a key, it is faster and more reliable than browser scraping.
33
-
34
- ```python
35
- import json, urllib.request
36
-
37
- API_KEY = "your_token_here"
38
-
39
- def g2_api_get(path, params=""):
40
- url = f"https://data.g2.com/api/v1/{path}?{params}"
41
- req = urllib.request.Request(url, headers={
42
- "Authorization": f"Token token={API_KEY}",
43
- "Content-Type": "application/vnd.api+json",
44
- "Accept": "application/json",
45
- })
46
- with urllib.request.urlopen(req, timeout=20) as r:
47
- return json.loads(r.read())
48
-
49
- # 1. Lookup product UUID by slug
50
- products = g2_api_get("products", "filter[slug]=slack")
51
- product = products["data"][0]
52
- product_id = product["id"] # UUID, e.g. "ac7841ad-cca8-4125-ac6f-6ef6b5848781"
53
- attrs = product["attributes"]
54
- print(f"{attrs['name']}: {attrs['star_rating']} stars, {attrs['review_count']} reviews")
55
- # star_rating: float 0-5 (overall)
56
- # avg_rating: string e.g. "4.5" (same thing, different format)
57
- # review_count: total published reviews
58
- # public_detail_url: "https://www.g2.com/products/slack/reviews"
59
-
60
- # 2. Fetch reviews (survey-responses) for that product
61
- # page[size] max 100, page[number] starts at 1
62
- page = 1
63
- all_reviews = []
64
- while True:
65
- batch = g2_api_get(
66
- f"products/{product_id}/survey-responses",
67
- f"page[number]={page}&page[size]=100"
68
- )
69
- reviews = batch["data"]
70
- if not reviews:
71
- break
72
- for r in reviews:
73
- a = r["attributes"]
74
- all_reviews.append({
75
- "id": r["id"],
76
- "title": a["title"],
77
- "star_rating": a["star_rating"], # float 0-5
78
- "pros": a["comment_answers"].get("love", ""), # varies by product
79
- "cons": a["comment_answers"].get("hate", ""),
80
- "user_name": a["user_name"],
81
- "country": a["country_name"],
82
- "submitted_at": a["submitted_at"],
83
- "source": a["review_source"],
84
- })
85
- meta = batch.get("meta", {})
86
- if page >= meta.get("page_count", 1):
87
- break
88
- page += 1
89
-
90
- print(f"Fetched {len(all_reviews)} reviews")
91
- ```
92
-
93
- ### API filter parameters
94
-
95
- **Products** (`GET /api/v1/products`):
96
-
97
- | Parameter | Description |
98
- |---|---|
99
- | `filter[slug]` | Exact URL slug (e.g. `slack`) |
100
- | `filter[name]` | Product name (fuzzy) |
101
- | `filter[domain]` | Domain of product website |
102
- | `page[size]` | Default 10, max 100 |
103
- | `page[number]` | Page number |
104
-
105
- **Survey-responses** (`GET /api/v1/survey-responses` or `/api/v1/products/{id}/survey-responses`):
106
-
107
- | Parameter | Description |
108
- |---|---|
109
- | `filter[submitted_at_gt]` | Min review submission time (RFC 3339) |
110
- | `filter[submitted_at_lt]` | Max review submission time |
111
- | `filter[moderated_at_gt]` | Min publication time |
112
- | `filter[star_rating]` | Filter by star rating |
113
- | `page[size]` | Default 10, max 100 |
114
-
115
- **Rate limit:** 100 requests/second. Exceeded = blocked for 60 seconds.
116
-
117
- ### Survey-response field reference
118
-
119
- ```
120
- star_rating float 0-5
121
- title string (review headline)
122
- comment_answers dict — keys vary by product's question set
123
- common keys: "love" (pros), "hate" (cons), "benefit" (who benefits)
124
- secondary_answers dict — additional structured answers
125
- is_public bool — reviewer consented to attribution
126
- user_name string
127
- country_name string
128
- regions list[string]
129
- submitted_at ISO 8601 datetime
130
- moderated_at ISO 8601 datetime (when published)
131
- review_source "Organic review..." or incentivized text
132
- votes_up int — helpful votes
133
- votes_down int
134
- product_id UUID
135
- slug URL slug for the individual review
136
- ```
137
-
138
- ---
139
-
140
- ## Browser approach (no API key required)
141
-
142
- ### Setup: open in new tab, wait for DataDome to clear
143
-
144
- ```python
145
- new_tab("https://www.g2.com/products/slack/reviews")
146
- wait_for_load()
147
- wait(5) # DataDome JS fingerprinting runs 2-4s after readyState=complete
148
- ```
149
-
150
- `wait(5)` is mandatory. Extracting before it completes returns empty or blocked content.
151
-
152
- Verify you are on the real page, not the DataDome challenge page:
153
-
154
- ```python
155
- title = js("document.title")
156
- url_now = page_info()["url"]
157
- if "g2.com" not in url_now or "captcha-delivery.com" in url_now:
158
- wait(5)
159
- title = js("document.title")
160
- url_now = page_info()["url"]
161
- assert "captcha-delivery.com" not in url_now, f"Still on DataDome challenge: {url_now}"
162
- ```
163
-
164
- ---
165
-
166
- ## URL patterns
167
-
168
- | Goal | URL |
169
- |---|---|
170
- | Product reviews | `/products/{slug}/reviews` |
171
- | Product reviews page 2+ | `/products/{slug}/reviews?page=2` |
172
- | Single review | `/products/{slug}/reviews/{review-slug}` |
173
- | Product overview | `/products/{slug}` |
174
- | Category listing | `/categories/{slug}` |
175
- | Category grid | `/categories/{slug}/grids` (disallowed in robots.txt — may not render) |
176
- | Compare | `/compare/{slug1}-vs-{slug2}` |
177
-
178
- Product slug is the lowercase hyphenated name from the URL: `slack`, `microsoft-teams`, `notion`, `salesforce-sales-cloud`.
179
-
180
- ---
181
-
182
- ## Workflow 1: Product rating and review count
183
-
184
- G2 is a **Rails app** (not Next.js) — there is no `__NEXT_DATA__`. Use schema.org microdata attributes.
185
-
186
- ```python
187
- import json
188
-
189
- goto_url("https://www.g2.com/products/slack/reviews")
190
- wait_for_load()
191
- wait(5)
192
-
193
- summary = js("""
194
- (function() {
195
- // Schema.org AggregateRating microdata — most reliable, SSR-rendered
196
- var aggEl = document.querySelector('[itemtype*="AggregateRating"]');
197
- var ratingVal = aggEl ? aggEl.querySelector('[itemprop="ratingValue"]') : null;
198
- var reviewCt = aggEl ? aggEl.querySelector('[itemprop="reviewCount"]') : null;
199
-
200
- // Fallback: plain text in the header band
201
- var ratingFb = document.querySelector('.x-current-rating, [data-next-head] ~ * .fw-bold, .star-rating__stars');
202
- var countFb = document.querySelector('.link-color-inherit, .reviews-count');
203
-
204
- // Product name
205
- var nameEl = document.querySelector('[itemprop="name"], h1.l1');
206
-
207
- return JSON.stringify({
208
- name: nameEl ? nameEl.innerText.trim() : '',
209
- rating: ratingVal ? ratingVal.getAttribute('content') || ratingVal.innerText.trim() : '',
210
- review_count: reviewCt ? reviewCt.getAttribute('content') || reviewCt.innerText.trim() : '',
211
- rating_fb: ratingFb ? ratingFb.innerText.trim() : '',
212
- count_fb: countFb ? countFb.innerText.trim() : '',
213
- });
214
- })()
215
- """)
216
-
217
- data = json.loads(summary)
218
- print("Product:", data["name"])
219
- print("Rating:", data["rating"] or data["rating_fb"])
220
- print("Reviews:", data["review_count"] or data["count_fb"])
221
- ```
222
-
223
- ---
224
-
225
- ## Workflow 2: Star distribution (rating breakdown)
226
-
227
- The rating distribution histogram (5-star, 4-star, …) is rendered server-side with a progress bar or percentage spans.
228
-
229
- ```python
230
- import json
231
-
232
- goto_url("https://www.g2.com/products/slack/reviews")
233
- wait_for_load()
234
- wait(5)
235
-
236
- dist = js("""
237
- (function() {
238
- // G2 renders star distribution in a table or bar list
239
- // Selector targets the rating breakdown rows
240
- var rows = document.querySelectorAll(
241
- '[data-star-rating], .rating-breakdown__row, .star-distribution tr, [class*="StarBreakdown"]'
242
- );
243
- var result = {};
244
- for (var i = 0; i < rows.length; i++) {
245
- var r = rows[i];
246
- // Star level: look for a number or aria-label containing the star count
247
- var starEl = r.querySelector('[data-star], .star-count, [class*="starCount"], td:first-child');
248
- var pctEl = r.querySelector('[data-percentage], .pct, [class*="percentage"], td:last-child');
249
- var countEl = r.querySelector('[data-count], .count-text');
250
- var star = starEl ? starEl.innerText.trim() : '';
251
- if (star && /^[1-5]/.test(star)) {
252
- result[star] = {
253
- pct: pctEl ? pctEl.innerText.trim() : '',
254
- count: countEl ? countEl.innerText.trim() : '',
255
- };
256
- }
257
- }
258
- // If nothing found, try aria-label approach for SVG-based bars
259
- if (!Object.keys(result).length) {
260
- var bars = document.querySelectorAll('[aria-label*="star"], [aria-label*="-star"]');
261
- for (var j = 0; j < bars.length; j++) {
262
- var lbl = bars[j].getAttribute('aria-label') || '';
263
- var m = lbl.match(/(\d)-star.*?(\d+\.?\d*)%/i);
264
- if (m) result[m[1]] = { pct: m[2] + '%', count: '' };
265
- }
266
- }
267
- return JSON.stringify(result);
268
- })()
269
- """)
270
-
271
- distribution = json.loads(dist)
272
- for star in ["5", "4", "3", "2", "1"]:
273
- d = distribution.get(star, {})
274
- print(f"{star}★: {d.get('pct','?')} ({d.get('count','?')})")
275
- ```
276
-
277
- If the distribution returns empty, take a screenshot and inspect the actual element structure:
278
-
279
- ```python
280
- capture_screenshot("/tmp/g2_reviews.png")
281
- # Inspect the image, then adjust selectors above
282
- ```
283
-
284
- ---
285
-
286
- ## Workflow 3: Extract individual review cards
287
-
288
- G2 renders reviews server-side as schema.org `Review` microdata items. Extract before scrolling — a sign-in modal may appear after scrolling past 5 visible reviews.
289
-
290
- ```python
291
- import json
292
-
293
- goto_url("https://www.g2.com/products/slack/reviews")
294
- wait_for_load()
295
- wait(5)
296
-
297
- # Dismiss cookie consent banner (GDPR regions)
298
- dismissed = js("""
299
- (function() {
300
- var btns = [
301
- '#onetrust-accept-btn-handler',
302
- 'button[id*="accept"]',
303
- 'button[class*="consent"]',
304
- '.js-cookie-consent-button',
305
- ];
306
- for (var i = 0; i < btns.length; i++) {
307
- var b = document.querySelector(btns[i]);
308
- if (b && b.offsetParent !== null) { b.click(); return btns[i]; }
309
- }
310
- return null;
311
- })()
312
- """)
313
- if dismissed:
314
- wait(1)
315
-
316
- reviews = js("""
317
- (function() {
318
- // Primary: schema.org Review microdata (SSR-rendered, stable)
319
- var cards = document.querySelectorAll(
320
- '[itemtype*="schema.org/Review"], [data-survey-id], .paper--box[data-id]'
321
- );
322
- if (!cards.length) {
323
- // Fallback: G2's newer CSS class patterns
324
- cards = document.querySelectorAll(
325
- '[class*="ReviewCard"], [class*="review-card"], article[class*="review"]'
326
- );
327
- }
328
- var out = [];
329
- for (var i = 0; i < cards.length; i++) {
330
- var c = cards[i];
331
-
332
- // Overall star rating
333
- var ratingEl = c.querySelector('[itemprop="ratingValue"], [class*="starRating"], .x-star-rating');
334
- var stars = ratingEl ? (ratingEl.getAttribute('content') || ratingEl.innerText.trim()) : '';
335
-
336
- // Review title
337
- var titleEl = c.querySelector('[itemprop="name"], h3[class*="title"], .review-title');
338
- var title = titleEl ? titleEl.innerText.trim() : '';
339
-
340
- // Review body (pros/cons are usually separate elements within reviewBody)
341
- var bodyEl = c.querySelector('[itemprop="reviewBody"]');
342
- var body = bodyEl ? bodyEl.innerText.trim() : '';
343
-
344
- // Explicit pros / cons when rendered as separate sections
345
- var prosEl = c.querySelector('[class*="pros"], [data-pros]');
346
- var consEl = c.querySelector('[class*="cons"], [data-cons]');
347
- var pros = prosEl ? prosEl.innerText.trim() : '';
348
- var cons = consEl ? consEl.innerText.trim() : '';
349
-
350
- // Reviewer job title / company
351
- var jobEl = c.querySelector('[class*="reviewer-title"], [class*="authorTitle"], [itemprop="jobTitle"]');
352
- var jobTitle = jobEl ? jobEl.innerText.trim() : '';
353
-
354
- // Date
355
- var dateEl = c.querySelector('time[itemprop="datePublished"], [itemprop="datePublished"]');
356
- var date = dateEl ? (dateEl.getAttribute('datetime') || dateEl.innerText.trim()) : '';
357
-
358
- // Survey ID (internal review ID)
359
- var surveyId = c.getAttribute('data-survey-id') || c.getAttribute('data-id') || '';
360
-
361
- if (title || pros || body) {
362
- out.push({ surveyId, stars, title, pros, cons, body, jobTitle, date });
363
- }
364
- }
365
- return JSON.stringify(out);
366
- })()
367
- """)
368
-
369
- results = json.loads(reviews)
370
- for r in results:
371
- print(f"{r['stars']}★ | {r['title']} | {r['jobTitle']} | {r['date']}")
372
- if r['pros']: print(f" + {r['pros'][:120]}")
373
- if r['cons']: print(f" - {r['cons'][:120]}")
374
- if r['body'] and not r['pros']: print(f" {r['body'][:200]}")
375
- ```
376
-
377
- **If `results` is empty:** G2 may have re-skinned. Take a screenshot and inspect the DOM:
378
-
379
- ```python
380
- capture_screenshot("/tmp/g2_page.png")
381
- # Check element structure with:
382
- structure = js("""
383
- (function() {
384
- // Dump first article/div with 'review' in its classes
385
- var el = document.querySelector(
386
- 'article, [class*="review"], [class*="Review"], [data-survey-id]'
387
- );
388
- return el ? el.outerHTML.slice(0, 2000) : 'NOT FOUND';
389
- })()
390
- """)
391
- print(structure)
392
- ```
393
-
394
- ---
395
-
396
- ## Workflow 4: Review pagination
397
-
398
- G2 paginates reviews via `?page=N` query parameter (Rails standard).
399
-
400
- ```python
401
- import json
402
-
403
- slug = "slack"
404
- all_reviews = []
405
-
406
- for page_num in range(1, 6): # up to 5 pages (~10 reviews each)
407
- url = f"https://www.g2.com/products/{slug}/reviews?page={page_num}"
408
- if page_num == 1:
409
- goto_url(url)
410
- else:
411
- goto_url(url)
412
- wait_for_load()
413
- wait(4 if page_num == 1 else 2) # DataDome only challenges on first page in session
414
-
415
- batch_json = js("""
416
- (function() {
417
- var cards = document.querySelectorAll(
418
- '[itemtype*="schema.org/Review"], [data-survey-id], [class*="ReviewCard"]'
419
- );
420
- var out = [];
421
- for (var i = 0; i < cards.length; i++) {
422
- var c = cards[i];
423
- var ratingEl = c.querySelector('[itemprop="ratingValue"]');
424
- var titleEl = c.querySelector('[itemprop="name"]');
425
- var bodyEl = c.querySelector('[itemprop="reviewBody"]');
426
- var dateEl = c.querySelector('time[itemprop="datePublished"]');
427
- var jobEl = c.querySelector('[itemprop="jobTitle"]');
428
- out.push({
429
- stars: ratingEl ? (ratingEl.getAttribute('content') || ratingEl.innerText.trim()) : '',
430
- title: titleEl ? titleEl.innerText.trim() : '',
431
- body: bodyEl ? bodyEl.innerText.trim() : '',
432
- date: dateEl ? (dateEl.getAttribute('datetime') || dateEl.innerText.trim()) : '',
433
- jobTitle: jobEl ? jobEl.innerText.trim() : '',
434
- });
435
- }
436
- return JSON.stringify(out.filter(r => r.title || r.body));
437
- })()
438
- """)
439
-
440
- batch = json.loads(batch_json)
441
- if not batch:
442
- break # no more reviews
443
- all_reviews.extend(batch)
444
- print(f"Page {page_num}: {len(batch)} reviews")
445
-
446
- print(f"Total: {len(all_reviews)} reviews")
447
- ```
448
-
449
- ---
450
-
451
- ## Workflow 5: Category product listing
452
-
453
- ```python
454
- import json
455
-
456
- goto_url("https://www.g2.com/categories/team-collaboration")
457
- wait_for_load()
458
- wait(5)
459
-
460
- products = js("""
461
- (function() {
462
- // Product cards in category listing
463
- var cards = document.querySelectorAll(
464
- '[itemtype*="SoftwareApplication"], [data-product-id], [class*="ProductCard"], [class*="product-listing"]'
465
- );
466
- var out = [];
467
- for (var i = 0; i < cards.length; i++) {
468
- var c = cards[i];
469
- var nameEl = c.querySelector('[itemprop="name"], h3, h2, [class*="productName"]');
470
- var ratingEl = c.querySelector('[itemprop="ratingValue"], [class*="rating"]');
471
- var countEl = c.querySelector('[itemprop="reviewCount"], [class*="reviewCount"]');
472
- var linkEl = c.querySelector('a[href*="/products/"]');
473
- var imgEl = c.querySelector('img[itemprop="image"], img[class*="logo"]');
474
- out.push({
475
- name: nameEl ? nameEl.innerText.trim() : '',
476
- rating: ratingEl ? (ratingEl.getAttribute('content') || ratingEl.innerText.trim()) : '',
477
- reviews: countEl ? (countEl.getAttribute('content') || countEl.innerText.trim()) : '',
478
- url: linkEl ? linkEl.href : '',
479
- logo: imgEl ? imgEl.src : '',
480
- });
481
- }
482
- return JSON.stringify(out.filter(p => p.name));
483
- })()
484
- """)
485
-
486
- listing = json.loads(products)
487
- for p in listing:
488
- print(f"{p['name']}: {p['rating']}★ ({p['reviews']} reviews)")
489
- ```
490
-
491
- ---
492
-
493
- ## Detecting DataDome challenge vs. real page
494
-
495
- ```python
496
- def g2_is_datadome_blocked() -> bool:
497
- """True if DataDome challenge is still running (not on the real G2 page)."""
498
- url_now = page_info()["url"]
499
- title = js("document.title") or ""
500
- return (
501
- "captcha-delivery.com" in url_now
502
- or "datadome" in url_now.lower()
503
- or title.strip() == "g2.com" # DataDome 403 response has title="g2.com"
504
- )
505
-
506
- # Usage
507
- new_tab("https://www.g2.com/products/slack/reviews")
508
- wait_for_load()
509
- wait(5)
510
-
511
- if g2_is_datadome_blocked():
512
- wait(10) # give DataDome JS extra time to complete
513
- if g2_is_datadome_blocked():
514
- capture_screenshot("/tmp/g2_dd_block.png")
515
- raise RuntimeError("DataDome challenge did not resolve — check screenshot")
516
- ```
517
-
518
- ---
519
-
520
- ## Handling the sign-in modal
521
-
522
- A login modal appears after scrolling past ~5 reviews (triggered by scroll, not on load). Extract all visible review cards **before scrolling**. If you need to scroll:
523
-
524
- ```python
525
- def dismiss_g2_login_modal():
526
- """Close G2's sign-in overlay. Safe to call if no modal is present."""
527
- closed = js("""
528
- (function() {
529
- var selectors = [
530
- '[data-close-modal], [data-modal-close]',
531
- 'button[aria-label="Close"]',
532
- '[class*="modal"] button[class*="close"]',
533
- '[class*="Modal"] button[class*="close"]',
534
- '.modal-dialog .close',
535
- 'button.close',
536
- ];
537
- for (var i = 0; i < selectors.length; i++) {
538
- var btn = document.querySelector(selectors[i]);
539
- if (btn && btn.offsetParent !== null) {
540
- btn.click();
541
- return selectors[i];
542
- }
543
- }
544
- return null;
545
- })()
546
- """)
547
- if closed:
548
- wait(1)
549
- return closed
550
- ```
551
-
552
- Call `dismiss_g2_login_modal()` after any scroll action that might trigger the modal.
553
-
554
- ---
555
-
556
- ## Gotchas
557
-
558
- - **`http_get` is permanently blocked.** DataDome 5.6.1 intercepts every Python `urllib` / `requests` call. The blocking signal is `X-DataDome: protected` + `X-DD-B: 1` in the response header, response body `rt:'c'` (CAPTCHA). No User-Agent, header set, or cookie replay bypasses it because the `datadome` cookie is bound to the originating TLS fingerprint. Without a real browser's TLS/JA3 fingerprint, the cookie is rejected as `rt:'i'` (invalid).
559
-
560
- - **DataDome does NOT block real Chrome via CDP.** The harness connects to Chrome via CDP. Chrome presents a genuine JA3 TLS fingerprint plus browser APIs (canvas, WebGL, Navigator). DataDome's fingerprinting sees a real browser and issues a valid `datadome` cookie silently (no CAPTCHA widget, no user action needed).
561
-
562
- - **`wait(5)` minimum after `wait_for_load()`.** DataDome's JS runs 2–4 seconds after `readyState='complete'`. The challenge page title is `"g2.com"` (not "G2 | Software Reviews..."). Checking `document.title` reliably distinguishes challenge from real page.
563
-
564
- - **G2 is a Rails app — no `__NEXT_DATA__`.** Unlike Next.js sites, G2 does NOT embed page data in a JSON script tag. All data must be extracted from the rendered HTML or via the official API. G2 uses Hotwire (Turbo + Stimulus) for frontend interactivity.
565
-
566
- - **Schema.org microdata is the reliable extraction path.** G2 bakes `itemtype` / `itemprop` attributes into their SSR HTML. These are stable across visual redesigns because they serve SEO purposes. Prefer `[itemprop="ratingValue"]` over class-based selectors.
567
-
568
- - **`comment_answers` key names vary by product.** The API's `comment_answers` dict uses question-specific keys that differ across products. Common keys include `"love"` (what do you like best?), `"hate"` (what do you dislike?), `"benefit"` (what benefits?), but these are not guaranteed. Inspect the raw response first.
569
-
570
- - **Sign-in modal triggers on scroll.** G2 limits anonymous visitors to the reviews visible in the initial viewport (~5 reviews). Scrolling triggers a login modal. Extract all initial cards before any scroll call. To get more reviews without login, use `?page=2`, `?page=3`, etc. instead of scrolling.
571
-
572
- - **Rate limiting on navigation.** G2 does not publish a browser-facing rate limit, but rapid consecutive `goto_url()` calls (< 2s apart) can trigger soft blocks. Use `wait(3)` between product page navigations and `wait(2)` between paginated review pages in the same session.
573
-
574
- - **Cloudflare is CDN-only here, not Bot Management.** The `Server: cloudflare` header and `__cf_bm` cookie are standard Cloudflare CDN features (not the Cloudflare Bot Management product). The actual anti-bot protection is DataDome. Do not apply Glassdoor-style CF challenge waits — the DataDome wait is what matters.
575
-
576
- - **`data.g2.com` API needs a vendor token.** The API requires `Authorization: Token token=<key>`. The key is obtained by registering as a G2 vendor or partner at `https://www.g2.com/sells`. The 401 response body is `{"errors":[{"status":"401","title":"Bad Credentials"}]}` — no further auth clues.
577
-
578
- - **Product UUIDs are required for the API.** The API uses UUIDs (e.g. `ac7841ad-cca8-4125-ac6f-6ef6b5848781`) not slugs for relationship endpoints like `/products/{id}/survey-responses`. Look up the UUID first via `GET /api/v1/products?filter[slug]=slack`.
579
-
580
- - **`/categories/*/grids` is disallowed in robots.txt** — may return 403 or empty content even in a browser session.
1
+ # G2 — B2B Software Reviews
2
+
3
+ Field-tested against g2.com on 2026-04-18.
4
+
5
+ ## Anti-bot verdict: browser required — DataDome blocks every http_get request
6
+
7
+ `http_get` returns HTTP 403 on every g2.com URL without exception.
8
+
9
+ Tested URLs (all 403):
10
+ - `https://www.g2.com/products/slack/reviews`
11
+ - `https://www.g2.com/categories/team-collaboration`
12
+ - `https://www.g2.com/products/slack`
13
+ - `https://www.g2.com/products/slack/reviews.json`
14
+ - `https://www.g2.com/blog/` (and most `www.g2.com/*`)
15
+
16
+ UAs tested (all blocked): `Mozilla/5.0`, full Chrome 124 macOS, Googlebot.
17
+
18
+ **Stack:**
19
+ - **Primary:** DataDome 5.6.1 (`X-DataDome: protected`, `X-DD-B: 1`). Response mode `rt:'c'` = CAPTCHA challenge. Mode `rt:'i'` = invalid/replayed cookie. The `datadome=...` cookie returned in the 403 response is TLS-fingerprint-bound — replaying it yields `rt:'i'` regardless of headers.
20
+ - **Secondary:** Cloudflare CDN (`Server: cloudflare`, `CF-RAY` header present).
21
+
22
+ DataDome's challenge is **silent** — no CAPTCHA widget appears in a real browser. JS fingerprinting runs post-DOM-ready and resolves automatically. A real Chrome session via CDP passes cleanly.
23
+
24
+ Pages **not** behind DataDome (safe to `http_get`): `help.g2.com`, `research.g2.com`, `learn.g2.com`, `data.g2.com/api/docs`.
25
+
26
+ **Use `goto_url()` + `wait()` exclusively. Never use `http_get` for www.g2.com.**
27
+
28
+ ---
29
+
30
+ ## Fastest approach: official vendor API (if you have a key)
31
+
32
+ G2 provides a public REST API at `https://data.g2.com/api/v1` documented at `https://data.g2.com/api/docs`. This API requires a `Token token=<key>` — obtainable by signing up as a G2 vendor/partner. If you have a key, it is faster and more reliable than browser scraping.
33
+
34
+ ```python
35
+ import json, urllib.request
36
+
37
+ API_KEY = "your_token_here"
38
+
39
+ def g2_api_get(path, params=""):
40
+ url = f"https://data.g2.com/api/v1/{path}?{params}"
41
+ req = urllib.request.Request(url, headers={
42
+ "Authorization": f"Token token={API_KEY}",
43
+ "Content-Type": "application/vnd.api+json",
44
+ "Accept": "application/json",
45
+ })
46
+ with urllib.request.urlopen(req, timeout=20) as r:
47
+ return json.loads(r.read())
48
+
49
+ # 1. Lookup product UUID by slug
50
+ products = g2_api_get("products", "filter[slug]=slack")
51
+ product = products["data"][0]
52
+ product_id = product["id"] # UUID, e.g. "ac7841ad-cca8-4125-ac6f-6ef6b5848781"
53
+ attrs = product["attributes"]
54
+ print(f"{attrs['name']}: {attrs['star_rating']} stars, {attrs['review_count']} reviews")
55
+ # star_rating: float 0-5 (overall)
56
+ # avg_rating: string e.g. "4.5" (same thing, different format)
57
+ # review_count: total published reviews
58
+ # public_detail_url: "https://www.g2.com/products/slack/reviews"
59
+
60
+ # 2. Fetch reviews (survey-responses) for that product
61
+ # page[size] max 100, page[number] starts at 1
62
+ page = 1
63
+ all_reviews = []
64
+ while True:
65
+ batch = g2_api_get(
66
+ f"products/{product_id}/survey-responses",
67
+ f"page[number]={page}&page[size]=100"
68
+ )
69
+ reviews = batch["data"]
70
+ if not reviews:
71
+ break
72
+ for r in reviews:
73
+ a = r["attributes"]
74
+ all_reviews.append({
75
+ "id": r["id"],
76
+ "title": a["title"],
77
+ "star_rating": a["star_rating"], # float 0-5
78
+ "pros": a["comment_answers"].get("love", ""), # varies by product
79
+ "cons": a["comment_answers"].get("hate", ""),
80
+ "user_name": a["user_name"],
81
+ "country": a["country_name"],
82
+ "submitted_at": a["submitted_at"],
83
+ "source": a["review_source"],
84
+ })
85
+ meta = batch.get("meta", {})
86
+ if page >= meta.get("page_count", 1):
87
+ break
88
+ page += 1
89
+
90
+ print(f"Fetched {len(all_reviews)} reviews")
91
+ ```
92
+
93
+ ### API filter parameters
94
+
95
+ **Products** (`GET /api/v1/products`):
96
+
97
+ | Parameter | Description |
98
+ |---|---|
99
+ | `filter[slug]` | Exact URL slug (e.g. `slack`) |
100
+ | `filter[name]` | Product name (fuzzy) |
101
+ | `filter[domain]` | Domain of product website |
102
+ | `page[size]` | Default 10, max 100 |
103
+ | `page[number]` | Page number |
104
+
105
+ **Survey-responses** (`GET /api/v1/survey-responses` or `/api/v1/products/{id}/survey-responses`):
106
+
107
+ | Parameter | Description |
108
+ |---|---|
109
+ | `filter[submitted_at_gt]` | Min review submission time (RFC 3339) |
110
+ | `filter[submitted_at_lt]` | Max review submission time |
111
+ | `filter[moderated_at_gt]` | Min publication time |
112
+ | `filter[star_rating]` | Filter by star rating |
113
+ | `page[size]` | Default 10, max 100 |
114
+
115
+ **Rate limit:** 100 requests/second. Exceeded = blocked for 60 seconds.
116
+
117
+ ### Survey-response field reference
118
+
119
+ ```
120
+ star_rating float 0-5
121
+ title string (review headline)
122
+ comment_answers dict — keys vary by product's question set
123
+ common keys: "love" (pros), "hate" (cons), "benefit" (who benefits)
124
+ secondary_answers dict — additional structured answers
125
+ is_public bool — reviewer consented to attribution
126
+ user_name string
127
+ country_name string
128
+ regions list[string]
129
+ submitted_at ISO 8601 datetime
130
+ moderated_at ISO 8601 datetime (when published)
131
+ review_source "Organic review..." or incentivized text
132
+ votes_up int — helpful votes
133
+ votes_down int
134
+ product_id UUID
135
+ slug URL slug for the individual review
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Browser approach (no API key required)
141
+
142
+ ### Setup: open in new tab, wait for DataDome to clear
143
+
144
+ ```python
145
+ new_tab("https://www.g2.com/products/slack/reviews")
146
+ wait_for_load()
147
+ wait(5) # DataDome JS fingerprinting runs 2-4s after readyState=complete
148
+ ```
149
+
150
+ `wait(5)` is mandatory. Extracting before it completes returns empty or blocked content.
151
+
152
+ Verify you are on the real page, not the DataDome challenge page:
153
+
154
+ ```python
155
+ title = js("document.title")
156
+ url_now = page_info()["url"]
157
+ if "g2.com" not in url_now or "captcha-delivery.com" in url_now:
158
+ wait(5)
159
+ title = js("document.title")
160
+ url_now = page_info()["url"]
161
+ assert "captcha-delivery.com" not in url_now, f"Still on DataDome challenge: {url_now}"
162
+ ```
163
+
164
+ ---
165
+
166
+ ## URL patterns
167
+
168
+ | Goal | URL |
169
+ |---|---|
170
+ | Product reviews | `/products/{slug}/reviews` |
171
+ | Product reviews page 2+ | `/products/{slug}/reviews?page=2` |
172
+ | Single review | `/products/{slug}/reviews/{review-slug}` |
173
+ | Product overview | `/products/{slug}` |
174
+ | Category listing | `/categories/{slug}` |
175
+ | Category grid | `/categories/{slug}/grids` (disallowed in robots.txt — may not render) |
176
+ | Compare | `/compare/{slug1}-vs-{slug2}` |
177
+
178
+ Product slug is the lowercase hyphenated name from the URL: `slack`, `microsoft-teams`, `notion`, `salesforce-sales-cloud`.
179
+
180
+ ---
181
+
182
+ ## Workflow 1: Product rating and review count
183
+
184
+ G2 is a **Rails app** (not Next.js) — there is no `__NEXT_DATA__`. Use schema.org microdata attributes.
185
+
186
+ ```python
187
+ import json
188
+
189
+ goto_url("https://www.g2.com/products/slack/reviews")
190
+ wait_for_load()
191
+ wait(5)
192
+
193
+ summary = js("""
194
+ (function() {
195
+ // Schema.org AggregateRating microdata — most reliable, SSR-rendered
196
+ var aggEl = document.querySelector('[itemtype*="AggregateRating"]');
197
+ var ratingVal = aggEl ? aggEl.querySelector('[itemprop="ratingValue"]') : null;
198
+ var reviewCt = aggEl ? aggEl.querySelector('[itemprop="reviewCount"]') : null;
199
+
200
+ // Fallback: plain text in the header band
201
+ var ratingFb = document.querySelector('.x-current-rating, [data-next-head] ~ * .fw-bold, .star-rating__stars');
202
+ var countFb = document.querySelector('.link-color-inherit, .reviews-count');
203
+
204
+ // Product name
205
+ var nameEl = document.querySelector('[itemprop="name"], h1.l1');
206
+
207
+ return JSON.stringify({
208
+ name: nameEl ? nameEl.innerText.trim() : '',
209
+ rating: ratingVal ? ratingVal.getAttribute('content') || ratingVal.innerText.trim() : '',
210
+ review_count: reviewCt ? reviewCt.getAttribute('content') || reviewCt.innerText.trim() : '',
211
+ rating_fb: ratingFb ? ratingFb.innerText.trim() : '',
212
+ count_fb: countFb ? countFb.innerText.trim() : '',
213
+ });
214
+ })()
215
+ """)
216
+
217
+ data = json.loads(summary)
218
+ print("Product:", data["name"])
219
+ print("Rating:", data["rating"] or data["rating_fb"])
220
+ print("Reviews:", data["review_count"] or data["count_fb"])
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Workflow 2: Star distribution (rating breakdown)
226
+
227
+ The rating distribution histogram (5-star, 4-star, …) is rendered server-side with a progress bar or percentage spans.
228
+
229
+ ```python
230
+ import json
231
+
232
+ goto_url("https://www.g2.com/products/slack/reviews")
233
+ wait_for_load()
234
+ wait(5)
235
+
236
+ dist = js("""
237
+ (function() {
238
+ // G2 renders star distribution in a table or bar list
239
+ // Selector targets the rating breakdown rows
240
+ var rows = document.querySelectorAll(
241
+ '[data-star-rating], .rating-breakdown__row, .star-distribution tr, [class*="StarBreakdown"]'
242
+ );
243
+ var result = {};
244
+ for (var i = 0; i < rows.length; i++) {
245
+ var r = rows[i];
246
+ // Star level: look for a number or aria-label containing the star count
247
+ var starEl = r.querySelector('[data-star], .star-count, [class*="starCount"], td:first-child');
248
+ var pctEl = r.querySelector('[data-percentage], .pct, [class*="percentage"], td:last-child');
249
+ var countEl = r.querySelector('[data-count], .count-text');
250
+ var star = starEl ? starEl.innerText.trim() : '';
251
+ if (star && /^[1-5]/.test(star)) {
252
+ result[star] = {
253
+ pct: pctEl ? pctEl.innerText.trim() : '',
254
+ count: countEl ? countEl.innerText.trim() : '',
255
+ };
256
+ }
257
+ }
258
+ // If nothing found, try aria-label approach for SVG-based bars
259
+ if (!Object.keys(result).length) {
260
+ var bars = document.querySelectorAll('[aria-label*="star"], [aria-label*="-star"]');
261
+ for (var j = 0; j < bars.length; j++) {
262
+ var lbl = bars[j].getAttribute('aria-label') || '';
263
+ var m = lbl.match(/(\d)-star.*?(\d+\.?\d*)%/i);
264
+ if (m) result[m[1]] = { pct: m[2] + '%', count: '' };
265
+ }
266
+ }
267
+ return JSON.stringify(result);
268
+ })()
269
+ """)
270
+
271
+ distribution = json.loads(dist)
272
+ for star in ["5", "4", "3", "2", "1"]:
273
+ d = distribution.get(star, {})
274
+ print(f"{star}★: {d.get('pct','?')} ({d.get('count','?')})")
275
+ ```
276
+
277
+ If the distribution returns empty, take a screenshot and inspect the actual element structure:
278
+
279
+ ```python
280
+ capture_screenshot("/tmp/g2_reviews.png")
281
+ # Inspect the image, then adjust selectors above
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Workflow 3: Extract individual review cards
287
+
288
+ G2 renders reviews server-side as schema.org `Review` microdata items. Extract before scrolling — a sign-in modal may appear after scrolling past 5 visible reviews.
289
+
290
+ ```python
291
+ import json
292
+
293
+ goto_url("https://www.g2.com/products/slack/reviews")
294
+ wait_for_load()
295
+ wait(5)
296
+
297
+ # Dismiss cookie consent banner (GDPR regions)
298
+ dismissed = js("""
299
+ (function() {
300
+ var btns = [
301
+ '#onetrust-accept-btn-handler',
302
+ 'button[id*="accept"]',
303
+ 'button[class*="consent"]',
304
+ '.js-cookie-consent-button',
305
+ ];
306
+ for (var i = 0; i < btns.length; i++) {
307
+ var b = document.querySelector(btns[i]);
308
+ if (b && b.offsetParent !== null) { b.click(); return btns[i]; }
309
+ }
310
+ return null;
311
+ })()
312
+ """)
313
+ if dismissed:
314
+ wait(1)
315
+
316
+ reviews = js("""
317
+ (function() {
318
+ // Primary: schema.org Review microdata (SSR-rendered, stable)
319
+ var cards = document.querySelectorAll(
320
+ '[itemtype*="schema.org/Review"], [data-survey-id], .paper--box[data-id]'
321
+ );
322
+ if (!cards.length) {
323
+ // Fallback: G2's newer CSS class patterns
324
+ cards = document.querySelectorAll(
325
+ '[class*="ReviewCard"], [class*="review-card"], article[class*="review"]'
326
+ );
327
+ }
328
+ var out = [];
329
+ for (var i = 0; i < cards.length; i++) {
330
+ var c = cards[i];
331
+
332
+ // Overall star rating
333
+ var ratingEl = c.querySelector('[itemprop="ratingValue"], [class*="starRating"], .x-star-rating');
334
+ var stars = ratingEl ? (ratingEl.getAttribute('content') || ratingEl.innerText.trim()) : '';
335
+
336
+ // Review title
337
+ var titleEl = c.querySelector('[itemprop="name"], h3[class*="title"], .review-title');
338
+ var title = titleEl ? titleEl.innerText.trim() : '';
339
+
340
+ // Review body (pros/cons are usually separate elements within reviewBody)
341
+ var bodyEl = c.querySelector('[itemprop="reviewBody"]');
342
+ var body = bodyEl ? bodyEl.innerText.trim() : '';
343
+
344
+ // Explicit pros / cons when rendered as separate sections
345
+ var prosEl = c.querySelector('[class*="pros"], [data-pros]');
346
+ var consEl = c.querySelector('[class*="cons"], [data-cons]');
347
+ var pros = prosEl ? prosEl.innerText.trim() : '';
348
+ var cons = consEl ? consEl.innerText.trim() : '';
349
+
350
+ // Reviewer job title / company
351
+ var jobEl = c.querySelector('[class*="reviewer-title"], [class*="authorTitle"], [itemprop="jobTitle"]');
352
+ var jobTitle = jobEl ? jobEl.innerText.trim() : '';
353
+
354
+ // Date
355
+ var dateEl = c.querySelector('time[itemprop="datePublished"], [itemprop="datePublished"]');
356
+ var date = dateEl ? (dateEl.getAttribute('datetime') || dateEl.innerText.trim()) : '';
357
+
358
+ // Survey ID (internal review ID)
359
+ var surveyId = c.getAttribute('data-survey-id') || c.getAttribute('data-id') || '';
360
+
361
+ if (title || pros || body) {
362
+ out.push({ surveyId, stars, title, pros, cons, body, jobTitle, date });
363
+ }
364
+ }
365
+ return JSON.stringify(out);
366
+ })()
367
+ """)
368
+
369
+ results = json.loads(reviews)
370
+ for r in results:
371
+ print(f"{r['stars']}★ | {r['title']} | {r['jobTitle']} | {r['date']}")
372
+ if r['pros']: print(f" + {r['pros'][:120]}")
373
+ if r['cons']: print(f" - {r['cons'][:120]}")
374
+ if r['body'] and not r['pros']: print(f" {r['body'][:200]}")
375
+ ```
376
+
377
+ **If `results` is empty:** G2 may have re-skinned. Take a screenshot and inspect the DOM:
378
+
379
+ ```python
380
+ capture_screenshot("/tmp/g2_page.png")
381
+ # Check element structure with:
382
+ structure = js("""
383
+ (function() {
384
+ // Dump first article/div with 'review' in its classes
385
+ var el = document.querySelector(
386
+ 'article, [class*="review"], [class*="Review"], [data-survey-id]'
387
+ );
388
+ return el ? el.outerHTML.slice(0, 2000) : 'NOT FOUND';
389
+ })()
390
+ """)
391
+ print(structure)
392
+ ```
393
+
394
+ ---
395
+
396
+ ## Workflow 4: Review pagination
397
+
398
+ G2 paginates reviews via `?page=N` query parameter (Rails standard).
399
+
400
+ ```python
401
+ import json
402
+
403
+ slug = "slack"
404
+ all_reviews = []
405
+
406
+ for page_num in range(1, 6): # up to 5 pages (~10 reviews each)
407
+ url = f"https://www.g2.com/products/{slug}/reviews?page={page_num}"
408
+ if page_num == 1:
409
+ goto_url(url)
410
+ else:
411
+ goto_url(url)
412
+ wait_for_load()
413
+ wait(4 if page_num == 1 else 2) # DataDome only challenges on first page in session
414
+
415
+ batch_json = js("""
416
+ (function() {
417
+ var cards = document.querySelectorAll(
418
+ '[itemtype*="schema.org/Review"], [data-survey-id], [class*="ReviewCard"]'
419
+ );
420
+ var out = [];
421
+ for (var i = 0; i < cards.length; i++) {
422
+ var c = cards[i];
423
+ var ratingEl = c.querySelector('[itemprop="ratingValue"]');
424
+ var titleEl = c.querySelector('[itemprop="name"]');
425
+ var bodyEl = c.querySelector('[itemprop="reviewBody"]');
426
+ var dateEl = c.querySelector('time[itemprop="datePublished"]');
427
+ var jobEl = c.querySelector('[itemprop="jobTitle"]');
428
+ out.push({
429
+ stars: ratingEl ? (ratingEl.getAttribute('content') || ratingEl.innerText.trim()) : '',
430
+ title: titleEl ? titleEl.innerText.trim() : '',
431
+ body: bodyEl ? bodyEl.innerText.trim() : '',
432
+ date: dateEl ? (dateEl.getAttribute('datetime') || dateEl.innerText.trim()) : '',
433
+ jobTitle: jobEl ? jobEl.innerText.trim() : '',
434
+ });
435
+ }
436
+ return JSON.stringify(out.filter(r => r.title || r.body));
437
+ })()
438
+ """)
439
+
440
+ batch = json.loads(batch_json)
441
+ if not batch:
442
+ break # no more reviews
443
+ all_reviews.extend(batch)
444
+ print(f"Page {page_num}: {len(batch)} reviews")
445
+
446
+ print(f"Total: {len(all_reviews)} reviews")
447
+ ```
448
+
449
+ ---
450
+
451
+ ## Workflow 5: Category product listing
452
+
453
+ ```python
454
+ import json
455
+
456
+ goto_url("https://www.g2.com/categories/team-collaboration")
457
+ wait_for_load()
458
+ wait(5)
459
+
460
+ products = js("""
461
+ (function() {
462
+ // Product cards in category listing
463
+ var cards = document.querySelectorAll(
464
+ '[itemtype*="SoftwareApplication"], [data-product-id], [class*="ProductCard"], [class*="product-listing"]'
465
+ );
466
+ var out = [];
467
+ for (var i = 0; i < cards.length; i++) {
468
+ var c = cards[i];
469
+ var nameEl = c.querySelector('[itemprop="name"], h3, h2, [class*="productName"]');
470
+ var ratingEl = c.querySelector('[itemprop="ratingValue"], [class*="rating"]');
471
+ var countEl = c.querySelector('[itemprop="reviewCount"], [class*="reviewCount"]');
472
+ var linkEl = c.querySelector('a[href*="/products/"]');
473
+ var imgEl = c.querySelector('img[itemprop="image"], img[class*="logo"]');
474
+ out.push({
475
+ name: nameEl ? nameEl.innerText.trim() : '',
476
+ rating: ratingEl ? (ratingEl.getAttribute('content') || ratingEl.innerText.trim()) : '',
477
+ reviews: countEl ? (countEl.getAttribute('content') || countEl.innerText.trim()) : '',
478
+ url: linkEl ? linkEl.href : '',
479
+ logo: imgEl ? imgEl.src : '',
480
+ });
481
+ }
482
+ return JSON.stringify(out.filter(p => p.name));
483
+ })()
484
+ """)
485
+
486
+ listing = json.loads(products)
487
+ for p in listing:
488
+ print(f"{p['name']}: {p['rating']}★ ({p['reviews']} reviews)")
489
+ ```
490
+
491
+ ---
492
+
493
+ ## Detecting DataDome challenge vs. real page
494
+
495
+ ```python
496
+ def g2_is_datadome_blocked() -> bool:
497
+ """True if DataDome challenge is still running (not on the real G2 page)."""
498
+ url_now = page_info()["url"]
499
+ title = js("document.title") or ""
500
+ return (
501
+ "captcha-delivery.com" in url_now
502
+ or "datadome" in url_now.lower()
503
+ or title.strip() == "g2.com" # DataDome 403 response has title="g2.com"
504
+ )
505
+
506
+ # Usage
507
+ new_tab("https://www.g2.com/products/slack/reviews")
508
+ wait_for_load()
509
+ wait(5)
510
+
511
+ if g2_is_datadome_blocked():
512
+ wait(10) # give DataDome JS extra time to complete
513
+ if g2_is_datadome_blocked():
514
+ capture_screenshot("/tmp/g2_dd_block.png")
515
+ raise RuntimeError("DataDome challenge did not resolve — check screenshot")
516
+ ```
517
+
518
+ ---
519
+
520
+ ## Handling the sign-in modal
521
+
522
+ A login modal appears after scrolling past ~5 reviews (triggered by scroll, not on load). Extract all visible review cards **before scrolling**. If you need to scroll:
523
+
524
+ ```python
525
+ def dismiss_g2_login_modal():
526
+ """Close G2's sign-in overlay. Safe to call if no modal is present."""
527
+ closed = js("""
528
+ (function() {
529
+ var selectors = [
530
+ '[data-close-modal], [data-modal-close]',
531
+ 'button[aria-label="Close"]',
532
+ '[class*="modal"] button[class*="close"]',
533
+ '[class*="Modal"] button[class*="close"]',
534
+ '.modal-dialog .close',
535
+ 'button.close',
536
+ ];
537
+ for (var i = 0; i < selectors.length; i++) {
538
+ var btn = document.querySelector(selectors[i]);
539
+ if (btn && btn.offsetParent !== null) {
540
+ btn.click();
541
+ return selectors[i];
542
+ }
543
+ }
544
+ return null;
545
+ })()
546
+ """)
547
+ if closed:
548
+ wait(1)
549
+ return closed
550
+ ```
551
+
552
+ Call `dismiss_g2_login_modal()` after any scroll action that might trigger the modal.
553
+
554
+ ---
555
+
556
+ ## Gotchas
557
+
558
+ - **`http_get` is permanently blocked.** DataDome 5.6.1 intercepts every Python `urllib` / `requests` call. The blocking signal is `X-DataDome: protected` + `X-DD-B: 1` in the response header, response body `rt:'c'` (CAPTCHA). No User-Agent, header set, or cookie replay bypasses it because the `datadome` cookie is bound to the originating TLS fingerprint. Without a real browser's TLS/JA3 fingerprint, the cookie is rejected as `rt:'i'` (invalid).
559
+
560
+ - **DataDome does NOT block real Chrome via CDP.** The harness connects to Chrome via CDP. Chrome presents a genuine JA3 TLS fingerprint plus browser APIs (canvas, WebGL, Navigator). DataDome's fingerprinting sees a real browser and issues a valid `datadome` cookie silently (no CAPTCHA widget, no user action needed).
561
+
562
+ - **`wait(5)` minimum after `wait_for_load()`.** DataDome's JS runs 2–4 seconds after `readyState='complete'`. The challenge page title is `"g2.com"` (not "G2 | Software Reviews..."). Checking `document.title` reliably distinguishes challenge from real page.
563
+
564
+ - **G2 is a Rails app — no `__NEXT_DATA__`.** Unlike Next.js sites, G2 does NOT embed page data in a JSON script tag. All data must be extracted from the rendered HTML or via the official API. G2 uses Hotwire (Turbo + Stimulus) for frontend interactivity.
565
+
566
+ - **Schema.org microdata is the reliable extraction path.** G2 bakes `itemtype` / `itemprop` attributes into their SSR HTML. These are stable across visual redesigns because they serve SEO purposes. Prefer `[itemprop="ratingValue"]` over class-based selectors.
567
+
568
+ - **`comment_answers` key names vary by product.** The API's `comment_answers` dict uses question-specific keys that differ across products. Common keys include `"love"` (what do you like best?), `"hate"` (what do you dislike?), `"benefit"` (what benefits?), but these are not guaranteed. Inspect the raw response first.
569
+
570
+ - **Sign-in modal triggers on scroll.** G2 limits anonymous visitors to the reviews visible in the initial viewport (~5 reviews). Scrolling triggers a login modal. Extract all initial cards before any scroll call. To get more reviews without login, use `?page=2`, `?page=3`, etc. instead of scrolling.
571
+
572
+ - **Rate limiting on navigation.** G2 does not publish a browser-facing rate limit, but rapid consecutive `goto_url()` calls (< 2s apart) can trigger soft blocks. Use `wait(3)` between product page navigations and `wait(2)` between paginated review pages in the same session.
573
+
574
+ - **Cloudflare is CDN-only here, not Bot Management.** The `Server: cloudflare` header and `__cf_bm` cookie are standard Cloudflare CDN features (not the Cloudflare Bot Management product). The actual anti-bot protection is DataDome. Do not apply Glassdoor-style CF challenge waits — the DataDome wait is what matters.
575
+
576
+ - **`data.g2.com` API needs a vendor token.** The API requires `Authorization: Token token=<key>`. The key is obtained by registering as a G2 vendor or partner at `https://www.g2.com/sells`. The 401 response body is `{"errors":[{"status":"401","title":"Bad Credentials"}]}` — no further auth clues.
577
+
578
+ - **Product UUIDs are required for the API.** The API uses UUIDs (e.g. `ac7841ad-cca8-4125-ac6f-6ef6b5848781`) not slugs for relationship endpoints like `/products/{id}/survey-responses`. Look up the UUID first via `GET /api/v1/products?filter[slug]=slack`.
579
+
580
+ - **`/categories/*/grids` is disallowed in robots.txt** — may return 403 or empty content even in a browser session.