Hello everyone. When writing a fileindex.html, a block of html code withid="app"does not parse. Tell me what could be the problem?

Python code

import requests
from fake_useragent import UserAgent
def main():
    session= requests.Session()
    ua= UserAgent()
    headers= {
        "accept": "*/*",
        "user-agent": ua.chrome
    data= {
        "login": "***My login***",
        "password": "***My password***"
    url= "https://netology.ru/profile"
    link= "https://netology.ru/backend/api/user/sign_in"
    res= session.post(link, data=data, headers=headers)
    print(res) # <Response[200]>    profile_info= session.get(url, headers=headers).text
    with open("index.html", "w") as file:
if __name__== "__main__":

A piece of html code from the recorded fileindex.html

<body><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PWG78J" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><div id="app"></div><script type="text/javascript">

Maybe in the end you need to work not with session, but with res ?

fedor.chernolutsky2022-01-18 19:57:19

@fedor.chernolutsky tried your advice, didn't help. Throws AttributeError: 'Response' object has no attribute 'get'. res doesn't have a get method.

GRuler2022-01-19 10:06:46