Scrapy upload file

痴心易碎 提交于 2019-11-29 16:54:13
starrify

At this very moment Scrapy has no built-in support for uploading files.

File uploading via forms in HTTP was specified in RFC1867. According to the spec, an HTTP request with Content-Type: multipart/form-data is required (in your code it would be application/x-www-form-urlencoded).

To achieve file uploading with Scrapy, you would need to:

  1. Get familiar with the basic concepts of HTTP file uploading.
  2. Start with scrapy.Request (instead of FormRequest).
  3. Give it a proper Content-Type header value.
  4. Build the request body yourself.

See also: How does HTTP file upload work?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!