Issue
payload={'hi':'hello world'}
r = requests.post('http://httpbin.org/anything', params=payload, data={'foo': 'bar'})
Is there a way to post parameters and data separately in a FormRequest
in Scrapy, I checked the documentation (scrapy request docs) and I am only seeing formdata
to post data,can I send parameters as well?
anther question do websites care if I pile params and data into one dictionary in POST ?
Solution
params
are send in url like
http://httpbin.org/anything?hi=hello+world
so you can create this url manually in Scrapy
If you print r.text
and r.url
in your code then you should see params in url
{
# ... rest ...
"url": "https://httpbin.org/anything?hi=hello+world"
}
http://httpbin.org/anything?hi=hello+world
You can't send params
in dictionary data
.
Minimal code which shows it
import requests
payload = {'hi':'hello world'}
data = {'foo': 'bar'}
r = requests.post('http://httpbin.org/anything', params=payload, data=data)
print(r.text)
print(r.url)
Answered By - furas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.