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

Python 有没有生成 form-data 的模块

  •  
  •   qsnow6 · Feb 27, 2017 · 2561 views
    This topic created in 3504 days ago, the information mentioned may be changed or developed.

    经常用 scrapy 框架,但是这个框架的 GET/POST 方法没有抽象出上传文件的参数,想问下自带的库或者 scrapy 有没有生成 form-data 的模块,丢进去一个文件,然后就生成出对应的报文。。

    — xxx — 
    Content-Disposition: form-data; name=” name ”
    
    zhangsan 
    — xxx — 
    Content-Disposition: form-data; name=” from ”
    
    beijing 
    — xxx — 
    Content-Disposition: file; name=” record ”; filename=” record.txt ” 
    Content-Type: text/plain
    
    3 replies  •  2017-02-27 18:44:28 +08:00
    qsnow6
        1
    qsnow6  
    OP
       Feb 27, 2017
    from requests.models import encode_multipart_formdata
    qsnow6
        2
    qsnow6  
    OP
       Feb 27, 2017
    解决了,上面这个是 requests 的方法
    pepesii
        3
    pepesii  
       Feb 27, 2017 via iPhone
    有个 FormRequest 不知是不是你要的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   896 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 23:16 · PVG 07:16 · LAX 16:16 · JFK 19:16
    ♥ Do have faith in what you're doing.