Trixy
Trixy

Reputation: 321

Some html tags are missing when i write to a file using python requests

I am trying to login to a website using requests.The website requies token for its login. so decided to parse the html and write it to a file.txt But the file.txt is missing the token tag.

HTML code:

    <form id="pw_form" class="exception_password" action="/409514769/password" method="post" data-xsrf-protection="enabled">
                <input type="password" id="password" class="exception_password-input iris_input" name="password" placeholder="Enter password" autocomplete="off" data-validators="required">
                <input type="hidden" name="is_review" value="">
                <input type="hidden" name="is_file_transfer" value="">
                <input type="submit" value="Submit" class="iris_btn iris_btn--primary">
                <input type="hidden" name="token" value="4dc82c1a780e11667650f856da9b1d9fd31b176b.e7mu8nmqrb.1587446534"></form>

PYTHON code:

from requests import Session
with Session() as s:
    site = s.get("https://vimeo.com/409")
    with open('page.txt','w') as out:
        out.write(site.text)

This is what the file writes:

<form id="pw_form" class="exception_password" action="/409514769/password" method="post">
                <input type="password" id="password" class="exception_password-input iris_input" name="password" placeholder="Enter password" class="password iris_form_text" autocomplete="off" data-validators="required">
                <input type="hidden" name="is_review" value="">
                <input type="hidden" name="is_file_transfer" value="">
                <input type="submit" value="Submit" class="iris_btn iris_btn--primary">

                            </form>

What is happening here?

Upvotes: 0

Views: 107

Answers (1)

Trixy
Trixy

Reputation: 321

Website don't allow request from bot. One possible solution to this problem is to add headers while making the request.

Upvotes: 0

Related Questions