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

Python 爬虫中怎么讲 url 地址转义为文件名?

  •  
  •   wyy · Mar 15, 2018 · 4452 views
    This topic created in 2990 days ago, the information mentioned may be changed or developed.
    7 replies    2018-03-15 17:34:31 +08:00
    julyclyde
        1
    julyclyde  
       Mar 15, 2018
    什么文件的名?
    wyy
        2
    wyy  
    OP
       Mar 15, 2018   ❤️ 1
    urllib 中的 urlencode 就可以了,注意要用字典的形式作为输入 value
    wyy
        3
    wyy  
    OP
       Mar 15, 2018
    @julyclyde windows 系统中合法的文件名
    tarekyoog
        4
    tarekyoog  
       Mar 15, 2018 via Android
    url.split('/')[-1]
    netChen
        5
    netChen  
       Mar 15, 2018
    网址中的‘.’在 Windows 系统中应该不能做文件名
    binux
        6
    binux  
       Mar 15, 2018
    你要自己定一个转义规则
    Arthur2e5
        7
    Arthur2e5  
       Mar 15, 2018 via Android
    @netChen 当然可以。你下载个 bash-4.4.tar.gz 试试?


    @wyy urlencode 按 URL 合法性的会错过冒号之类一堆东西,闭着眼睛直接搞的又嫌浪费路径长度…还是需要自己列字符就是
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5301 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 08:43 · PVG 16:43 · LAX 01:43 · JFK 04:43
    ♥ Do have faith in what you're doing.