Scraping a website that requires authentication
<p>I know this question might seem quite straight forward, but I have tried every suggestion and none has worked.</p>

<p>I want to build a Python script that checks my school website to see if new grades have been put up. However I cannot for the life of me figure out how to scrape it.</p>

<p>The website redirects to a different page to login. I have tried all the scripts and answers I could find but I am lost.</p>

<p>I use Python 3, the website is in a <code>https://blah.schooldomate.state.edu.country/website/grades/summary.aspx</code> 
format</p>

<p>The username section contains the following:</p>

<p><code>&lt;input class="txt" id="username" name="username" type="text" autocomplete="off" style="cursor: auto;"&gt;</code></p>

<p>The password is the name except it contains an <code>onfocus</code> HTML element.</p>

<p>One successfully authenticated, I am automatically redirected to the correct page.</p>

<p>I have tried:</p>

<p>using Python 2's cookielib and Mechanize</p>

<p>Using HTTPBasicAuth</p>

<p>Passing the information as a dict to a requests.get()</p>

<p>Trying out many different peoples code including answers I found on this site</p>

<p>You can try with requests:
<a href="http://docs.python-requests.org/en/master/" rel="nofollow">http://docs.python-requests.org/en/master/</a></p>

<p>from the web site:</p>

<pre><code>import requests

r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
</code></pre>

python