NanmiCoder / NanmiCoder/MediaCrawler
[问题] 微博爬取评论数据返回302
Open
Nobody has claimed this yet.
question
- Dominant language
- Python
- Stars
- 65.3k
- Forks
- 12.6k
- PR merge metrics
- No merged PRs in 30d
Description
⚠️ 提交前确认
- 我已经仔细阅读了项目使用过程中的常见问题汇总
- 我已经搜索并查看了已关闭的issues
- 我确认这不是由于滑块验证码、Cookie过期、Cookie提取错误、平台风控等常见原因导致的问题
❓ 问题描述
微博爬取评论数据返回302
🔍 使用场景
- 目标平台: 微博
- 使用功能: 关键词搜索
💻 环境信息
- 操作系统: windown11
- Python版本: 3.9
- 是否使用IP代理: 否
- 是否使用VPN翻墙软件:否
- 目标平台(抖音/小红书/微博等): 微博
📋 错误日志
async def request(self, method, url, **kwargs) -> Union[Response, Dict]:
enable_return_response = kwargs.pop("return_response", False)
async with httpx.AsyncClient(proxies=self.proxies, verify=False) as client:
response = await client.request(
method, url, timeout=self.timeout,
**kwargs
)
if enable_return_response:
return response
data: Dict = response.json()
ok_code = data.get("ok")
if ok_code not in [0, 1]:
utils.logger.error(f"[WeiboClient.request] request {method}:{url} err, res:{data}")
raise DataFetchError(data.get("msg", "unkonw error"))
else:
return data.get("data", {})
data: Dict = response.json()报错 JSONDecodeError('Expecting value: line 1 column 1 (char 0)') debug发现response状态码为302
📷 错误截图
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WeiboClient.request method shown in the report and reproduce the keyword-search comment request on Python 3.9 and Windows 11. Inspect the httpx response when the status is 302 before response.json() is called. Done means the reported request behavior is understood and the crawler handles the response without the shown JSONDecodeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100