[Python] neopets login (no error checking)

Discussion in 'Code Snippets and Tutorials' started by planetpluto, Aug 19, 2007.

  1. planetpluto

    planetpluto Level I

    Joined:
    Aug 17, 2007
    Messages:
    53
    Likes Received:
    0
    Location:
    Toronto, Canada
    You'll need twill and python to run it.

    I'll be adding error checking shortly and hopefully be using this code in a python igloo autobuyer released under the gpl :yup:

    Code (Python):
    1. <div class="python" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> <span style="color: #808080; font-style: italic;">#!/usr/bin/python</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">username = <span style="color: #008000;">str</span><span style="color: black;">(</span><span style="color: #008000;">raw_input</span><span style="color: black;">(</span><span style="color: #483d8b;">"Enter username: "</span><span style="color: black;">)</span><span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">password = <span style="color: #008000;">str</span><span style="color: black;">(</span><span style="color: #008000;">raw_input</span><span style="color: black;">(</span><span style="color: #483d8b;">"Enter password: "</span><span style="color: black;">)</span><span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #ff7700;font-weight:bold;">from</span> twill <span style="color: #ff7700;font-weight:bold;">import</span> get_browser</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">b = get_browser<span style="color: black;">(</span><span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #ff7700;font-weight:bold;">from</span> twill.<span style="color: #dc143c;">commands</span> <span style="color: #ff7700;font-weight:bold;">import</span> *</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #ff7700;font-weight:bold;">def</span> login<span style="color: black;">(</span>usernm, passwd<span style="color: black;">)</span>:</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; go<span style="color: black;">(</span><span style="color: #483d8b;">"http://neopets.com/loginpage.phtml"</span><span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; fv<span style="color: black;">(</span><span style="color: #483d8b;">"1"</span>, <span style="color: #483d8b;">"username"</span>, usernm<span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; submit<span style="color: black;">(</span><span style="color: #483d8b;">'0'</span><span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">"Username Submitted"</span>, usernm</li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; fv<span style="color: black;">(</span><span style="color: #483d8b;">"1"</span>, <span style="color: #483d8b;">"password"</span>, passwd<span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; submit<span style="color: black;">(</span><span style="color: #483d8b;">'0'</span><span style="color: black;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">"Password Submitted"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> usernm, <span style="color: #483d8b;">"(hopefully) logged in"</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp;</li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">login<span style="color: black;">(</span>username,password<span style="color: black;">)</span></li></ol></div>