Stack Exchange 问题
将 Stack Exchange 问题、标签或搜索结果页面解析为结构化 JSON,包含每个问题的标题、得分、回答数和浏览数、标签、摘要、作者以及分页。
API 用法
在 Crawling API 请求中添加 &scraper=stackexchange-serp。在 url 参数中对目标 URL 进行 URL 编码。
curl 'https://api.crawlbase.com/?token=YOUR_TOKEN' \
--data-urlencode 'url=https://stackoverflow.com/questions/tagged/web-scraping' \
--data-urlencode 'scraper=stackexchange-serp' -Gfrom crawlbase import CrawlingAPI
api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
'https://stackoverflow.com/questions/tagged/web-scraping',
{'scraper': 'stackexchange-serp'}
)
import json
data = json.loads(res['body'])const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });
const res = await api.get(
'https://stackoverflow.com/questions/tagged/web-scraping',
{ scraper: 'stackexchange-serp' }
);
const data = JSON.parse(res.body);require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')
res = api.get('https://stackoverflow.com/questions/tagged/web-scraping', scraper: 'stackexchange-serp')
data = JSON.parse(res.body)示例输入 URL
url 参数支持任意 Stack Exchange 列表:网络中任意站点的标签、搜索或问题页面。例如:
https://stackoverflow.com/questions/tagged/web-scraping
https://superuser.com/search?q=ssh+tunnel
https://askubuntu.com/questions?tab=Votes
https://unix.stackexchange.com/questions/tagged/bash
https://mathoverflow.net/questions响应结构
JSON 响应体。当源页面省略对应值时,字段类型可能为 null。
结果来源的 Stack Exchange 站点(例如
stackoverflow)。产生这些结果的搜索查询或标签。
列表所限定的标签,若非标签页面则为 null。
应用于列表的排序方式(例如
newest、votes、active)。当前返回列表的页码(从 1 开始)。
与列表匹配的问题总数,若页面省略该计数则为 null。
本页的问题,按列表顺序排列。
问题在返回列表中的位置(从 1 开始)。
Stack Exchange 问题 id。
问题标题。
问题的规范 URL。
问题得分(顶数减去踩数)。
问题的回答数量。
问题的浏览数量。
当问题有已采纳的回答时为 true。
问题正文的简短摘要。
应用于问题的标签。
问题作者的显示名称。
问题作者的个人资料 URL。
问题创建时间(ISO 8601)。
results 中返回的结果数量。用于下一页的分页游标。
此响应覆盖的页码(从 1 开始)。
下一页结果的 URL,如果是最后一页则为 null。
当有下一页可用时为 true。
示例响应
{
"site": "stackoverflow.com",
"query": "web scraping infinite scroll pagination",
"tag": null,
"sort": "Relevance",
"currentPage": 1,
"totalQuestions": null,
"results": [
{
"position": 1,
"id": "78912345",
"title": "How to handle pagination when scraping an infinite scroll page?",
"questionUrl": "https://stackoverflow.com/questions/78912345/how-to-handle-pagination-when-scraping-an-infinite-scroll-page",
"score": 4,
"answerCount": 2,
"viewCount": 137,
"hasAcceptedAnswer": true,
"excerpt": "I'm trying to scrape a product listing that loads more items as you scroll. The network tab shows a POST request returning JSON, but the cursor token keeps changing...",
"tags": ["python", "web-scraping", "pagination", "requests"],
"author": "dev_ana",
"authorUrl": "https://stackoverflow.com/users/1234567/dev-ana",
"askedAt": "2026-07-15T09:42:11Z"
},
{
"position": 2,
"id": "78911002",
"title": "Rotating proxies with residential IPs to avoid rate limiting",
"questionUrl": "https://stackoverflow.com/questions/78911002/rotating-proxies-with-residential-ips-to-avoid-rate-limiting",
"score": 1,
"answerCount": 0,
"viewCount": 42,
"hasAcceptedAnswer": false,
"excerpt": "My crawler gets blocked after roughly 500 requests from a datacenter IP. I want to rotate through a residential proxy pool but I'm unsure how to detect a soft ban...",
"tags": ["web-scraping", "proxy", "http"],
"author": "crawler_joe",
"authorUrl": "https://stackoverflow.com/users/9988776/crawler-joe",
"askedAt": "2026-07-15T08:05:47Z"
}
],
"resultCount": 2,
"pagination": {
"currentPage": 1,
"nextPageUrl": "https://stackoverflow.com/search?q=web+scraping+infinite+scroll+pagination&tab=Relevance&page=2",
"hasNext": true
}
}