Python Forum
Login a Python Web Crawler on a ASP NET (.aspx) website - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Login a Python Web Crawler on a ASP NET (.aspx) website (/thread-6582.html)



Login a Python Web Crawler on a ASP NET (.aspx) website - p4t3x - Nov-29-2017



I'm developing a Web Crawler in Python 3.4 to Scrap some info from a Call Reporter platform developed in ASP.NET. I already did all the code to scrap the content I want and the only thing is left to finish my script is the login.
What i need to login a system built on ASP.NET by a Python Web Crawler?

The code below is the login part of my script:

import requests
from lxml import html

USERNAME = "<USERNAME>"
PASSWORD = "<PASSWORD>"

LOGIN_URL = "<LOGIN_URL"
URL = "<URL>"

def main():
    session_requests = requests.session()

    # Get login hash - VIEWSTATE
    result = session_requests.get(LOGIN_URL)
    tree = html.fromstring(result.text)
    HASH = list(set(tree.xpath("//input[@name='__VIEWSTATE']/@value")))[0]

    # Create payload
    payload = {
        "LoginViewControl$userLogonControl$UserName": USERNAME,
        "LoginViewControl$userLogonControl$Password": PASSWORD,
        "LoginViewControl$userLogonControl$DropDownLanguage": "English-US",
        "LoginViewControl$userLogonControl$PasswordHash": HASH
    }

    # Perform login
    session_requests.get(LOGIN_URL, data=payload, headers=dict(referer=LOGIN_URL))
	
	"""
	The script continues
	"""



RE: Login a Python Web Crawler on a ASP NET (.aspx) website - hshivaraj - Dec-01-2017

This is still not a very helpful post.
Its very difficult to validate or to advice anything without seeing the HTML.