Quantcast

Jump to content


Photo

Neopets Accounts Generator (I need some help)/Python

python neopets mechanize

  • Please log in to reply
8 replies to this topic

#1 Zombipster

Zombipster
  • 18 posts

Posted 08 August 2014 - 11:19 PM

Hi to everybody. These days I was looking for a neopets accounts generator but I didn't find any. So I decided to make my own program. I already have the name and the mail aspects solved, but, I have a problem: When I looked for the form to sign up in neopets I just can't find how they do it. I looked in the html code and im still lost. I use Mechanize to look for it, so, if anyone can show me how to fill the sign up form, I could release my program :) I'm not a professional programer. Sorry for my bad english, but I hope that someone will understand what a wrote :p Any help will be accept.


Edited by Zombipster, 08 August 2014 - 11:20 PM.


#2 Waser Lave

Waser Lave

  • 25516 posts


Users Awards

Posted 09 August 2014 - 02:20 AM

You should get into the habit of packet sniffing data which is being submitted so you can simulate the same data in your programs. You can get add-ons like Live HTTP Headers etc for your browser or something like Wireshark which shows you exactly what headers and data are being submitted while you're using your browser. ;)



#3 RedLoveBlackHeart

RedLoveBlackHeart
  • 265 posts


Users Awards

Posted 09 August 2014 - 10:59 AM

Hi to everybody. These days I was looking for a neopets accounts generator but I didn't find any. So I decided to make my own program. I already have the name and the mail aspects solved, but, I have a problem: When I looked for the form to sign up in neopets I just can't find how they do it. I looked in the html code and im still lost. I use Mechanize to look for it, so, if anyone can show me how to fill the sign up form, I could release my program :) I'm not a professional programer. Sorry for my bad english, but I hope that someone will understand what a wrote :p Any help will be accept.

 

Your english is fine. I hope you find someone who can help you. :)



#4 Zombipster

Zombipster
  • 18 posts

Posted 09 August 2014 - 05:12 PM

Well, I did what you tell me, I saw the html code and I get this:

html codeid='signupPage'>
Sign Up with Neopets (Step 1 of 4)
sf'>Your password must be at least 6 characters long, and include at least 2 numbers. You may also use !@#%^&*$+._() and capitalisation matters (A is different from a).Re-enter Password

And in Live HTTP headers I got:

Live HTTPPOST /signup/ajax.phtml method=step1&username=&password1=&password2=&terms=true&destination=

So, what I have to do? That the part of my code that i'm traying to complete:<blockquote class="ipsBlockquote">Quote<p>import mechanizeimport cookielibbr = mechanize.Browser()cj = cookielib.LWPCookieJar()br.set_cookiejar(cj)br.set_handle_robots(False)br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; es-VE; rv:1.9.0.1)Gecko/2008071615 Debian/6.0 Firefox/9')]br.open('

#5 Eefi

Eefi
  • 1337 h4x0r

  • 1626 posts


Users Awards

Posted 09 August 2014 - 11:47 PM

Is the POST form submitted via <form></form> or through javascript? Because I've only used mechanize with forms before and wouldn't know how to send arbitrary post data.



#6 Waser Lave

Waser Lave

  • 25516 posts


Users Awards

Posted 10 August 2014 - 12:30 AM

Looks like the forum decided to mess your post up, can you re-post it?
 
Normally you should be able to just url encode your data in a dictionary and post it in the open function, so something like:
 
params = {'username': USERNAME, 'password1': PASSWORD1 etc}
data = urllib.urlencode(params)
html = opener.open(url,data)


#7 Zombipster

Zombipster
  • 18 posts

Posted 10 August 2014 - 06:55 AM

oh yes, here is it again:

 

Well, I did what you tell me, I saw the html code and I get this:

 

HTML

 

<div id='signupPage'>

<div id='signupTitle'>
Sign Up with Neopets (Step 1 of 4)
</div>


<div id='signupProgressImg'>
<img src='http://images.neopets.com/reg/step_1_stars.gif' width='203' height='31' border='0'>
</div>
<div class='clear'></div>
<div>
<div id='stepContent'>
<img src='http://images.neopets.com/reg/step_1_mascot.gif' width='200' height='200' id='stepMascot'>
<table id='stepForm' cellpadding='2' cellspacing='0' border='0'><tr>
<td width='350' valign='top' class='signupCell'>
<b id='labelUsername'>Create a Username</b><br>
<span class='sf'>Your username must be between 6 and 20 characters long (letters, numbers or underscores only).</span>
</td><td width='195' valign='top' align='center'>
<input type='text' size='20' maxlength='20' value='' id='signupUsername' class='signupInput' onkeyup='updateName()' onblur='updateName()'><br>
<input type='button' value="Check availability" id='checkAvailability' class='signupInput' onclick='signupUpdate("checkAvailability", {"username": document.getElementById("signupUsername").value})' disabled='disabled'>
</td>
</tr><tr>
<td valign='top' class='signupCell'>
<b id='labelPassword1'>Create a Password</b><br>
<span class='sf'>Your password must be at least 6 characters long, and include at least 2 numbers. You may also use <span class='highlight'>!@#%^&*$+._()</span> and capitalisation matters (<span class='highlight'>A</span> is different from <span class='highlight'>a</span>).
</td><td valign='top' align='center'>
<input type='password' size='20' maxlength='20' id='signupPassword1' class='signupInput'>
</td>
</tr><tr>
<td valign='top' class='signupCell'>
<b id='labelPassword2'>Re-enter Password</b><br>
</td><td valign='top' align='center'>
<input type='password' size='20' maxlength='20' id='signupPassword2' class='signupInput'>
</td>
</tr>
<tr>
<td colspan='2'>
<input type='checkbox' id='signupTerms' value='1'>I agree to the <a href='/terms.phtml' target='_blank'><b>Terms of Use</b></a> & <a href='/privacy.phtml' target='_blank'><b>Privacy Policy</b></a>
</td>
</tr>
</table>
<div class='medText' id='signupMessage'>
&nbsp;
</div>
</div>

<div class='signupFooter'>
<img src='http://images.neopets.com/reg/next_link.png' width='250' height='40' border='0' class='signupNext' onclick='signupUpdate("step1", {"username": document.getElementById("signupUsername").value, "password1": document.getElementById("signupPassword1").value, "password2": document.getElementById("signupPassword2").value, "terms": document.getElementById("signupTerms").checked, "destination": ""}); return false;'>
</div>

<div class='clear'></div>

</div>

</div>

 

And in Live HTTP headers I got:

 

 

Live HTTP

POST /signup/ajax.phtml method=step1&username=&password1=&password2=&terms=true&destination=

 

So, what I have to do? That the part of my code that i'm traying to complete:

 

 

import mechanize
import cookielib

br = mechanize.Browser()
cj = cookielib.LWPCookieJar()

br.set_cookiejar(cj)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)

br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; es-VE; rv:1.9.0.1)Gecko/2008071615 Debian/6.0 Firefox/9')]

br.open('http://www.neopets.c.../index.phtml?')

br.select_form(nr=1)

for f in br.forms():
    print f
 


I guess trough javascript.



#8 Waser Lave

Waser Lave

  • 25516 posts


Users Awards

Posted 10 August 2014 - 06:58 AM

So in that code you've got already you're setting your user-agent and then requesting the signup page. So next you'll need to post the data so it'll be this part:

 

params = {'username': USERNAME, 'password1': PASSWORD1 etc}
data = urllib.urlencode(params)
html = opener.open(url,data)

 

So you plug in your variables which you've found from packet sniffing (method=step1&username=&password1=&password2=&terms=true&destination=), put those in your dictionary and then post the data to the url you've already got too (/signup/ajax.phtml):

 

html = opener.open(url,data)



#9 Zombipster

Zombipster
  • 18 posts

Posted 10 August 2014 - 11:41 AM

Well, thanks to everybody. I already done it, thank you so much :)


Edited by Zombipster, 11 August 2014 - 09:20 AM.




Also tagged with one or more of these keywords: python, neopets, mechanize

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users