1

I have a question about python request post. With the post, it still returns the searching page not the result page.

I have searched around, but I couldn't solve it by myself.

website: http://facilityquality.dads.state.tx.us/qrs/public/qrs.do?page=searchCity&lang=en&mode=P&dataSet=1&ctx=2630332

my code (headers are not included):

url_city_search='http://facilityquality.dads.state.tx.us/qrs/public/qrs.do?page=searchCity&lang=en&mode=P&dataSet=1&ctx=2630332'
data={"serviceTypeOption":"al_B","cityName":"Houston","dispatch":"citySearch"}
s = requests.Session()
providers=s.post(url_city_search,headers=headers,data=data,timeout=15, verify=True)
print providers.status_code
print providers.text
lmiguelvargasf
71.3k55 gold badges231 silver badges241 bronze badges
asked Apr 16, 2017 at 23:03

1 Answer 1

1

@sideshowbarker answered your question quite well, but I thought it was also worth adding that requests will handle building the parameter string for you if you pass a dict to the optional params argument in your request. It's easy to get the parameters wrong when building the string yourself.

import requests
url_params = {
 "page": "qrsSearchResults",
 "lang": "en",
 "mode": "P",
 "dataSet": "1"
}
url_base = "http://facilityquality.dads.state.tx.us/qrs/public/qrs.do"
data = {"serviceTypeOption":"al_B", "cityName":"Houston", "dispatch":"citySearch"}
s = requests.Session()
providers = s.post(url_base, params=url_params, data=data, timeout=15, verify=True)
print providers.status_code
print providers.text
answered Apr 18, 2017 at 15:00
Sign up to request clarification or add additional context in comments.

2 Comments

Good point. Actually, can’t the data members also being combined with the URL params? They are all just params and values too.
Yes! I wasn't sure if they were url parameters or form data, but they absolutely can (and should) be added.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.