Trying to use the Python Requests module to post to a form:
using Chrome/inspect/network tab after I search for something is shows:
Request URL:https://www.fbo.gov/index?s=opportunity&mode=list&tab=search Status Code:302 Found
The Request Payload is:
... begin snippet ....
procurement_notice ------WebKitFormBoundary9stOUHDiQLr2yrEB Content-Disposition: form-data; name="dnf_class_values[procurement_notice][notice_id]"
8045295a672345856701e8ff0ab87a4c ------WebKitFormBoundary9stOUHDiQLr2yrEB Content-Disposition: form-data; name="dnf_class_values[procurement_notice][_so_agent_save_agent]"
------WebKitFormBoundary9stOUHDiQLr2yrEB Content-Disposition: form-data; name="dnf_class_values[procurement_notice][custom_response_date]"
------WebKitFormBoundary9stOUHDiQLr2yrEB Content-Disposition: form-data; name="dnf_class_values[procurement_notice][custom_posted_date]"
30 ------WebKitFormBoundary9stOUHDiQLr2yrEB Content-Disposition: form-data; name="dnf_class_values[procurement_notice][keywords]"
Colorado
... end snippet ....
The code, I am trying is:
import requests
headers ={'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 GTB7.1 (.NET CLR 3.5.30729)'}
url = 'https://www.fbo.gov/index?s=opportunity&mode=list&tab=search'
search_data={"dnf_class_values[procurement_notice][keywords]":Colorado}
r = requests.post(url, data=search_data, headers=headers)
it doesn't give me the r.content as if I passed in the search term 'Colorado'.
So my question is does the 'Code:302', which is a re-direct, mean they don't accept a POST request and also how do I deal with the 'WebKitFormBoundary' ...'Content-Disposition: form-data...' as it doesn't look like a normal dictionary element I can pass in.