V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2017-02-27 15:22:52 +08:00 · 1897 次点击
    这是一个创建于 2622 天前的主题,其中的信息可能已经有所发展或是发生改变。

    经常用 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 条回复    2017-02-27 18:44:28 +08:00
    qsnow6
        1
    qsnow6  
    OP
       2017-02-27 15:35:58 +08:00
    from requests.models import encode_multipart_formdata
    qsnow6
        2
    qsnow6  
    OP
       2017-02-27 15:36:28 +08:00
    解决了,上面这个是 requests 的方法
    pepesii
        3
    pepesii  
       2017-02-27 18:44:28 +08:00 via iPhone
    有个 FormRequest 不知是不是你要的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2264 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 08:43 · PVG 16:43 · LAX 01:43 · JFK 04:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.