推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
qazwsxkevin
V2EX  ›  Python

Win7 有“本地连接”和"TAP",“WLAN",一共三个网络适配器,写 Python 遇上了这个问题困扰,目前无法解决。。。

  •  
  •   qazwsxkevin · May 12, 2020 · 2911 views
    This topic created in 2217 days ago, the information mentioned may be changed or developed.

    首先:
    PC 上装了 open*pn,连到公司(国内)的内网网段上,PC 创建有"TAP-Win32 Adapter V9"这个网络适配器,这个是不能去改变”有或者无“的前提,但允许去改变这个适配器的参数。。。

    代码里用了 request-html 这个已经过时的库(这个一时间无法改变)

    情况: 如果 TAP 适配器 enable 了,request-html 去获取网页,是 Timeout,tcp closed 的。
    ( by the way:这个pn 并不推送 0.0.0.0 的路由给本地,只是推送了公司内部网段的路由过来,所以 PC 机的路由 0/0,基本上还是全往本地网关走,而不是全走公司pn 了)

    如果把 net stop Open*PNService,关闭了服务,
    request-html 一切正常

    所以基本上能判断,pycharm 写的 python,肯定是首选了 TAP 适配器走流量, 尽管我尝试了这个方法把 TAP 设备调整到最后了,但依然情况依旧 http://www.xitongcheng.com/jiaocheng/win7_article_46610.html

    所以现在开着*PN,就无法进行 python 做 request-html 操作了, 请教大家,这个问题如何解决?

    这个是 WIN7 系统调整的问题
    还是 request-html 的网络接口机制问题?

    6 replies    2020-05-13 19:46:53 +08:00
    chinawrj
        1
    chinawrj  
       May 12, 2020
    通信时 bind 了 TAP 的 IP 地址?用 0.0.0.0 试试
    1462326016
        2
    1462326016  
       May 13, 2020
    也许你可以尝试修改本地路由,让你想访问的地址走本地适配器。
    我之前尝试过同事了连接两个适配器,一个内网,一个外网,调整了本地路由就可以了。
    仅供参考
    ghostwwg
        3
    ghostwwg  
       May 13, 2020
    看着感觉像是 open*** 拨号后修改了默认路由。拨号后默认流量走哪里?
    ghostwwg
        4
    ghostwwg  
       May 13, 2020
    @ghostwwg 审题不清,抱歉。
    julyclyde
        5
    julyclyde  
       May 13, 2020
    “肯定是”这话可不能随便说
    建议你抓包验证一下
    qazwsxkevin
        6
    qazwsxkevin  
    OP
       May 13, 2020
    谢谢各位大佬热心解答~

    问题已经得到解决,是 pyppeteer 的问题,根据
    https://github.com/psf/requests-html/issues/278#issuecomment-476950656
    这个答案,增加\pyppeteer\launcher.py 的 108,109 行
    ```
    #add following two lines
    '--proxy-server="direct://"',
    '--proxy-bypass-list=*'
    ```

    问题彻底解决!

    应该是 pyppeteer 自身缺陷的问题,时间水平所限,搞不懂机制的原理,解决问题就这样了,赶紧上车赶路才是正事
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1029 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 70ms · UTC 18:12 · PVG 02:12 · LAX 11:12 · JFK 14:12
    ♥ Do have faith in what you're doing.