Open ZRHann opened 6 months ago
This is odd. Perhaps it has something to do with the headers?
And when I modified it to
@login_required
def is_session_alive(self) -> bool:
steam_login = self.username
headers = {
'Cache-Control': 'max-age=0',
'Sec-Ch-Ua': '"Not?A_Brand";v="8", "Chromium";v="108"',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': "Windows",
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.125 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
}
main_page_response = self._session.get(SteamUrl.COMMUNITY_URL, headers=headers)
return steam_login.lower() in main_page_response.text.lower()
it was able to return True correctly.
Through the process of elimination, I found that adding Accept
to the headers can fix this issue. Namely:
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
}
When
get_my_inventory
correctly retrieved the inventory items,is_session_alive
returnedFalse
. Below is my code: