how do I python to login to forums/websites?

0 James Kon · September 15, 2015
The webcrawling tutorial only showed how to retrieve the code, the website I'm using needs to be logged into.

Python will need to click the username box, password box, and the login button, only then will I be able to crawl and get the data needed.

If anyone needs it, the website I'm using is http://inboot.me/members/login.php
I've also got the DDOS protection figured out by using this:
while title == "Just a moment...":
time.sleep(2)




(and yes, I have googled it. Only 1 old tutorial came up.)

Post a Reply

Replies

Oldest  Newest  Rating
0 Halcyon Abraham Ramirez · September 15, 2015
doing this is pretty tricky and sometimes not worthit

your better off using selenium webdriver as it'll act like a browser.

because using requests to log in. you'll need to follow the post request of the form and the hidden values accompanying the form

I asked this question too and found the answer on stackoverflow. I forgot what exact thread. you can google it up
but for the headaches it's worth. selenium is better especially because you want a simulation of a user input. which is what selenium web driver does
0 James Kon · September 15, 2015
Is it like AutoIt?

It could work with AutoIt or something like that, but I would prefer it all to be done in the background, so the user doesn't see the actual web page open.
0 Halcyon Abraham Ramirez · September 16, 2015
AutoIt? I haven't tried that.but maybe there is a minimize button for selenium? Im pretty sure there should be one.

You can actually see in real time what's happening to the webpage. You can always use the request route. but that's a huge pain in the a** but you can do that. look it up on stack overflow. submit form using requests
0 Bernard Pyc0d333 Parah · September 18, 2015
you can perfectly use python to login.
Check out the mechanize module and its usage, should do just fine.
0 James Kon · September 18, 2015
Thanks! Mechanize wasn't compatible with my version of Python, but MechanicalSoup seems to work with it.
0 James Kon · September 19, 2015
Mechanize has almost no documentation on it, this is becoming very frustrating. I'm using Python 3 and can't find anything that allows me to do it! With Mechanize it seems possible, but I can't use it if I don't know how!
+1 Halcyon Abraham Ramirez · September 19, 2015
dude I just mentioned selenium webdriver which does what mechanize does :/
0 James Kon · September 19, 2015
Selenium seems to be what I was looking for, however I get lots of errors when I open webdriver.chrome,

If you can help me at all, heres the pastebin of my code.
http://pastebin.com/jZjAbQ3C


Heres the errors I get:
http://pastebin.com/Gef4QNPd
0 Halcyon Abraham Ramirez · September 20, 2015
put the chromewebdriver.exe in your root python directory

http://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path
  • 1

Python

107,188 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator