推荐学习书目
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
maemo
V2EX  ›  Python

请教一个 python urllib 代理的问题

  •  
  •   maemo · May 30, 2016 · 2647 views
    This topic created in 3675 days ago, the information mentioned may be changed or developed.
    昨天买了一个短信宝,写了一个脚本,返回0表示成功,测试了可以发短信,把 url 复制到浏览器打开也可以发短信。然后到另一台电脑上就不行。

    另一台电脑是 ubuntu 12.04lts, 内网,不能上网,用的别人的代理。
    通过这个代理浏览器可以打开短信宝的网站,脚本返回值也是0,把 url 复制到浏览器打开也返回0,但是发不了短信到手机。

    然后,我在这台电脑上插了一个 usb 网卡,通过这个网卡上网,运行脚本,可以发送短信。

    请问一下这个可能是什么原因。还有 python 有没有哪个库指定双网卡中的一张网卡?因为这个 usb 网卡不是默认网卡,我也没 root 权限修改。
    5 replies    2016-06-01 08:39:04 +08:00
    jimzhong
        1
    jimzhong  
       May 30, 2016   ❤️ 1
    如果用 urllib 是不能指定网卡的。如果你写 socket 或许可以尝试 bind 。
    fcicq
        2
    fcicq  
       May 30, 2016
    pycurl?
    wuhang89
        3
    wuhang89  
       May 31, 2016
    使用 socket bind ip address 绑定出口是可行的
    建议你使用 request
    maemo
        4
    maemo  
    OP
       May 31, 2016
    @wuhang89 @jimzhong 我试了一下,结果不行,一直无法连接。
    jimzhong
        5
    jimzhong  
       Jun 1, 2016
    @maemo 你看一下路由表?`ip route show`
    有可能没有配从那个网卡走的默认路由
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3603 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 04:55 · PVG 12:55 · LAX 21:55 · JFK 00:55
    ♥ Do have faith in what you're doing.