NanmiCoder / NanmiCoder/MediaCrawler

[问题]

Open
#662 1 comment 0 reactions 0 assignees View on GitHub

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提取错误、平台风控等常见原因导致的问题

❓ 问题描述

不管怎么调整一直出现如下报错
playwright._impl._errors.TargetClosedError: Page.content: Target page, context or browser has been closed
采用的措施如下:
1.安装最新的httpx == 0.28.1
2.降低httpx == 0.24.0
3.清除缓存
4.检查pycharm解释器配置

🔍 使用场景

  • 目标平台:小红书
  • 使用功能:关键词搜索

💻 环境信息

  • 操作系统: win10
  • Python版本: 3.13
  • 是否使用IP代理: 是
  • 是否使用VPN翻墙软件:否
  • 目标平台(抖音/小红书/微博等): 小红书

📋 错误日志

C:\Users\user\AppData\Local\Programs\Python\Python313\python.exe D:\MediaCrawler\MediaCrawler-main\main.py 
2025-07-15 21:48:44 MediaCrawler INFO (proxy_ip_pool.py:59) - [ProxyIpPool._is_valid_proxy] testing 36.150.215.191 is it valid 
httpx_proxy: {'https://': 'http://d1046917462:o587r4de@36.150.215.191:20648'}
2025-07-15 21:48:47 MediaCrawler INFO (proxy_ip_pool.py:72) - [ProxyIpPool._is_valid_proxy] testing 36.150.215.191 status code: 502
2025-07-15 21:48:48 MediaCrawler INFO (proxy_ip_pool.py:59) - [ProxyIpPool._is_valid_proxy] testing 58.19.55.9 is it valid 
httpx_proxy: {'https://': 'http://d1046917462:o587r4de@58.19.55.9:19588'}
2025-07-15 21:48:51 MediaCrawler INFO (proxy_ip_pool.py:72) - [ProxyIpPool._is_valid_proxy] testing 58.19.55.9 status code: 503
httpx_proxy: {'https://': 'http://d1046917462:o587r4de@58.19.55.9:19588'}
2025-07-15 21:48:52 MediaCrawler INFO (proxy_ip_pool.py:59) - [ProxyIpPool._is_valid_proxy] testing 58.19.55.9 is it valid 
2025-07-15 21:48:55 MediaCrawler INFO (proxy_ip_pool.py:72) - [ProxyIpPool._is_valid_proxy] testing 58.19.55.9 status code: 503
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\tenacity\asyncio\__init__.py", line 114, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\MediaCrawler\MediaCrawler-main\proxy\proxy_ip_pool.py", line 100, in get_proxy
    raise Exception("[ProxyIpPool.get_proxy] current ip invalid and again get it")
Exception: [ProxyIpPool.get_proxy] current ip invalid and again get it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\MediaCrawler\MediaCrawler-main\main.py", line 75, in <module>
    asyncio.get_event_loop().run_until_complete(main())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "D:\MediaCrawler\MediaCrawler-main\main.py", line 65, in main
    await crawler.start()
  File "D:\MediaCrawler\MediaCrawler-main\media_platform\xhs\core.py", line 57, in start
    ip_proxy_info: IpInfoModel = await ip_proxy_pool.get_proxy()
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\tenacity\asyncio\__init__.py", line 189, in async_wrapped
    return await copy(fn, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\tenacity\asyncio\__init__.py", line 111, in __call__
    do = await self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\tenacity\asyncio\__init__.py", line 153, in iter
    result = await action(retry_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\tenacity\_utils.py", line 99, in inner
    return call(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python313\Lib\site-packages\tenacity\__init__.py", line 421, in exc_check
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x1b8deb3d310 state=finished raised Exception>]

📷 错误截图

Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with media_platform/xhs/core.py and proxy/proxy_ip_pool.py, following the keyword-search startup path from main.py. Reproduce the failure with the reported proxy setup and compare the reported TargetClosedError with the logged proxy-validation RetryError; done means the actual failure is identified and a focused fix or required configuration is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.