您可能需要一段時間才能做手工每一次得到一個新的JSESSIONID
,因爲它可能過期。
import requests
url = "http://bac.menara.ma/ministere/resultat.jsp"
payload = "texte2=%2324po8%23%234&txt1=12064608"
headers = {
'accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
'origin': "http//bac.menara.ma",
'user-agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36",
'content-type': "application/x-www-form-urlencoded",
'referer': "http//bac.menara.ma/ministere/",
'accept-encoding': "gzip, deflate",
'accept-language': "en-US,en;q=0.8",
'cookie': "JSESSIONID=7EF23C675238D7AC936A58CFCA5CBA35; ___utmgb=e#ebzb; __utmt=1; __utma=268890082.1354194921.1434543682.1434543682.1434543682.1; __utmb=268890082.3.10.1434543682; __utmc=268890082; __utmz=268890082.1434543682.1.1.utmcsr=stackoverflow.com|utmccn=(referral)|utmcmd=referral|utmcct=/questions/30891272/sending-post-method-manually-using-python"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
哪裏是你的代碼? – sgp