日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

python asp.net requests_python3使用requests访问asp页面时出错,返回500

發(fā)布時(shí)間:2024/9/3 asp.net 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python asp.net requests_python3使用requests访问asp页面时出错,返回500 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

學(xué)校的官微有個(gè)一鍵查成績的功能,我一直很想能做出來玩,現(xiàn)在在學(xué)習(xí)python,正好準(zhǔn)備拿來練手,但是訪問的時(shí)候卻出現(xiàn)了500錯(cuò)誤。

以下是代碼:

python

import requests

import time

import hashlib

from user import user

url1 = 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx'

url2 = 'http://202.115.133.173:805/Default.aspx'

url3 = 'http://202.115.133.173:805/MyMessage/MyMsgForm.aspx'

username = user.name

password = user.pwd

sign = int(time.time()*1000)

headers = {

'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',

'Accept-Encoding': 'gzip, deflate, compress',

'Accept-Language': 'en-us;q=0.5,en;q=0.3',

'Cache-Control': 'max-age=0',

'Connection': 'keep-alive',

'Host':'202.115.133.173:805',

'Referer':'',

'Upgrade-Insecure-Requests':'1',

'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'

}

def treatpwd(user, sign, pwd):

pwdmd5 = hashlib.md5()

pwdmd5.update(pwd.encode("utf-8"))

loginpwd = pwdmd5.hexdigest()

return loginpwd

datas = {

'Action':'Login',

'userName':username,

'pwd':treatpwd(username, sign, password),

'sign':sign,

}

if name == "__main__":

req = requests.Session()

headers['Referer'] = url1

print(headers)

req.headers.update(headers)

resp1 = req.post(url1,data=datas)

print(resp1)

headers['Referer'] = url1

print(headers)

req.headers.update(headers)

print(req.headers)

resp2 = req.get(url2)

print(resp2.headers)

headers['Referer'] = url2

req.headers.update(headers)

resp3 = req.get(url3)

print(resp3.headers)

print(resp3)

我在網(wǎng)上查詢了之后,發(fā)現(xiàn)可能是refer的問題,但是更新refer的時(shí)候又出了問題。

以下是輸出信息:

{'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept-Language': 'en-us;q=0.5,en;q=0.3', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Host': '202.115.133.173:805', 'Referer': 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}

{'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept-Language': 'en-us;q=0.5,en;q=0.3', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Host': '202.115.133.173:805', 'Referer': 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}

{'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Connection': 'keep-alive', 'Accept-Language': 'en-us;q=0.5,en;q=0.3', 'Cache-Control': 'max-age=0', 'Host': '202.115.133.173:805', 'Referer': 'http://202.115.133.173:805/Common/Handler/UserLogin.ashx', 'Upgrade-Insecure-Requests': '1'}

{'Content-Type': 'text/html', 'Content-Encoding': 'gzip', 'Last-Modified': 'Thu, 23 Nov 2017 03:09:08 GMT', 'Accept-Ranges': 'bytes', 'ETag': '"0a24a6d864d31:0"', 'Vary': 'Accept-Encoding', 'Server': 'Microsoft-IIS/7.5', 'X-Powered-By': 'ASP.NET', 'Date': 'Sat, 07 Apr 2018 13:19:10 GMT', 'Content-Length': '1329'}

{'Cache-Control': 'private', 'Content-Type': 'text/html; charset=utf-8', 'Server': 'Microsoft-IIS/7.5', 'X-AspNet-Version': '4.0.30319', 'X-Powered-By': 'ASP.NET', 'Date': 'Sat, 07 Apr 2018 13:19:11 GMT', 'Content-Length': '4179'}

Process finished with exit code 0

現(xiàn)在感覺有點(diǎn)暈,不知道應(yīng)該怎么做了。

順帶一提:我輸出登陸成功后的respons的源碼時(shí),發(fā)現(xiàn)也是不對,說明在登陸成功的頁面就出了問題。

總結(jié)

以上是生活随笔為你收集整理的python asp.net requests_python3使用requests访问asp页面时出错,返回500的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。