[英]Scrapy: send post in script way without Spider
#!/usr/bin/env python3
import scrapy
def errback(failure):
print(failure)
def callback(response):
print(response)
scrapy.FormRequest(r'https://example.com',
callback=callback,
errback=errback)
In the script above, neither errback nor callback is called.在上面的脚本中,既没有调用 errback 也没有调用回调。
What is the simplest way to send a post request to https://example.com
using scrapy in python3.在python3中使用scrapy将post请求发送到
https://example.com
的最简单方法是什么https://example.com
I'd like to avoid using a Spider class/object if possible.如果可能,我想避免使用 Spider 类/对象。
use requests
使用
requests
pip3 install requests
import requests
url = "[url]"
payload = {}
headers = {
#Headers here
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.