2

I am connecting my RaspberryPi to my school's WiFi network which is fine for local operations like SSH, but the school has a web login to associate the IP with a user account which grants internet access (Uses LightSpeed Systems). I'm using my raspberrypi headless, so I don't have any access to a browser and this resets roughly every 45 minutes (I have to log in again).

Is there a way that I could automate this process with a Python script?

Thanks

Clarification: In response to the comment: To use the internet at my school a login to a webpage is required (internal proxy) similar to what you would find at a hotel or airport. It makes you login every 45 minutes to have a connection to the outside internet. Could I get the Pi to automatically login via a script as it will be running headless.

  • Automate what? What is being reset every 45 minutes, why do you then have to log back in? Is something timing out because you haven't used the internet? – joan Nov 29 '14 at 15:19
  • @joan I added the clarification, thanks for letting me know I wasn't clear enough in my original answer :) – Clement Nov 29 '14 at 15:24
  • 1
    You could use the wget or curl commands to do an automatic login (man wget / man curl). The details would depend on what the login page requires. Googling "web page login with wget / curl " should bring up examples. – joan Nov 29 '14 at 15:52
1

The problem with this is it doesn't involve any kind of standard or protocol. That doesn't mean it isn't possible in general, it just means there probably isn't be a pre-existing solution in a specific case.

If you understand the nature of http exchanges and basic html, you could reverse engineer the login and automate it with, e.g., wget or curl or some simple client in python, perl, etc. You need to fetch the login page and then send an approporiate response, probably POST data but there could be other mechanisms. Watching an exchange with wireshark should enable you to see the details of what is going on. Cookies probably are not involved since you are authorizing yourself for low level internet access.

If you don't think you have the prerequisite knowledge for this, it is going to be too difficult to be worth bothering with.

1

My Solution:

I ended up writing a Python Script to log onto my School's network (LS Systems based). Thanks again to Goldilocks and Joan for their contributions, it helped massively. Firstly, I found the login fields view Formfind (perl script), then I located a URL which logged me out and then directed me through several redirects until presenting the user with the actual login page. The page is time sensitive so I had to actually view the page to get a unique ID so I could login. I could not copy and paste a solution from my computer. I then filled in the field after faking my User-Agent as my Mac from Safari and submitted the form. I did this via the Mechanize module which I installed easily via easy_install mechanize.

If anyone needs the code, let me know! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.