[Python] PYTHON 3 - How to web scrape a password protected website?

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to access a website in my work, however it's username/password protected. The user/pw pop-up also looks as in the picture.Login image I attach my code to view the website. I can see the HTML code, however with an error "401 Authorization Required". Can you please help?

    import requests
    from bs4 import BeautifulSoup as bs

    r = requests.get("http://10.75.19.101/mfgindex", auth=('root', 'password'))

    # Convert to beautiful soup object

    soup = bs(r.content, features="html.parser")

    # print
    print(soup.prettify())

    Continue reading...

Compartilhe esta Página