python - How to check if request post has been successfully posted? -
i'm using python requests module handle requests on particular website i'm crawling. i'm new http requests, understand basics. here's situation. there's form want submit , using post method requests module:
# create session session = requests.session() # page witch i'm going post url session.get(url) # create dictionary containing data post postdata = { 'param1': 'data1', 'param2': 'data2', } # post session.post(submiturl, data=postdata)
is there ways check if data has been posted? .status_code method way check that?
if pick result when post can check status code:
result = session.post(submiturl, data=postdata) if result.status_code == requests.codes.ok: # went well...
Comments
Post a Comment