我正在尝试使用Python中的请求向URL发送帖子请求。我收到500 ERROR消息。我认为问题在于没有在内容类型中正确编码为x-www-form-urlencoded。如果我在邮递员中尝试相同的请求,它就可以了。
我的Python代码:
import requests
def get_pdf_link_by_post(url, payload):
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
r = requests.post(url, data=payload, headers=headers)
print requests
print "**************Headers*******************"
print r.headers
print r.content
def process_kat_causelist(date, adv_name):
url = 'http://kat.kar.nic.in:8080/causelistsearch.jsp'
for court_hall_idx in range(1, 4):
court_hall = str(court_hall_idx)+'~Court Hall '+str(court_hall_idx)
for list_idx in range(1, 7):
list_num = str(list_idx)+'~List '+str(list_idx)
payload = {'firstClDate': date, 'secondCldate': date, 'courthall': court_hall, 'lists': list_num}
print payload
get_pdf_link_by_post(url, payload)
process_kat_causelist('25/08/2015', 'ani')
邮差要求:
答案 0 :(得分:0)
在有效负载中,secondCldate必须是secondClDate