PDA

View Full Version : Neolib v2



AliasXNeo
11-08-2014, 08:19 PM
Neolib 2 ([Only registered and activated users can see links])



Neolib is a python library which aims to automate the cult classic web based game, Neopets. Neolib automates the game from the ground up by centralizing actions around the Neopets user account. The library includes strong functionality for performing complex tasks as well as built-in querying of a user's assets.
Neolib is built upon python's famous requests library for handling HTTP communications and the powerful lxml library for parsing HTML content. These two libraries combine to give Neolib a powerful and fast framework for automation.

Neolib is aimed for being deployed on a server or cloud environment. The library does not assume that there will be a graphical interface for interacting with the library. Rather, it assumes the code will either be ran in a script on a server or as part of a grander program with a web interface.

Neolib is still in a very early stage of development. As such, things are expected to change, up to and including the base classes. If you intend on using the library in this state please ensure you check back frequently with the master branch for changes.

Neolib is also looking for developers interested in contributing to the project. A very detailed and useful primer can be found in the links below. Please read it and understand it fully before making contributions to the project.

Documentation: [Only registered and activated users can see links]
Contribution Primer: [Only registered and activated users can see links]

Author: Josh
Github: [Only registered and activated users can see links]
Documentation: [Only registered and activated users can see links]
Example Programs: [Only registered and activated users can see links]
Version: 0.1 (Beta)

As most have guessed, this is the second iteration of my Neolib library. Since Neopets is undergoing new management, some things have changed and I've deemed it necessary to simply rewrite the library from scratch rather than attempting to fix the first iteration. It also gives me an opportunity to implement new ideas like core classes and switching over to lxml from BeautifulSoup.

This is a great opportunity for new or non-experienced programmers to contribute towards something and learn a lot about Python. The current iteration of the library includes a lot of concepts from both the functional and object oriented disciplines. If you're interested please read through the primer and contact me to be added on as a contributor.

As the library progresses I will be releasing example programs to help stimulate use of the library. This programs will be publicly available and open source via the same Github repo.

Enjoy!

j03
11-09-2014, 06:03 PM
Great work. Always look forward to the stuff you contribute, especially after the last project you left us with! :D

AliasXNeo
11-09-2014, 06:30 PM
Great work. Always look forward to the stuff you contribute, especially after the last project you left us with! :D

Thanks!

I must admit it's turning out a lot better this time around. The use of lxml and xpath is making stuff pretty clean and very quick. I also just implemented a universal query method for searching inventories like so:


>>> usr.inventory.find(name='Carrot')
[Item <Carrot>]
>>> usr.inventory.find(name__startswith='C')
[Item <Carrot>]
>>> usr.inventory.find(desc__contains='carrot')
[Item <Carrot>]

I'll post back here in a little while with instructions on how interested parties can test the library's current features.

j03
11-09-2014, 06:39 PM
Damn, now that's feature packed lol. Just for the inventory it seems like you are covering a lot of functions that may come in handy at a later point. I'm interested in learning from this entire project and I will probably use some of the stuff for my future Python work. :)

AliasXNeo
11-10-2014, 04:34 PM
To start using it from Linux/Mac:

1. Ensure git is installed (apt-get install git)
2. Ensure python 3 is installed (apt-get install python3)
3. Ensure libxml and libxslt are installed on linux (apt-get install libxml2 libxslt)
4. Ensure development headers for python are installed (apt-get install python-dev)
5. Ensure pip is installed (apt-get install pyton3-pip)

6.Clone the repository:

$ git clone [Only registered and activated users can see links] neolib2

7.Install required libraries:

$ cd neolib2
$ pip install -r requirements.txt

You may need to substitute 'pip3' for 'pip'.

For Windows:

1. Ensure the latest version of python 3 is installed on your system
2. Download Github for Windows: [Only registered and activated users can see links]
3. Navigate to: [Only registered and activated users can see links] and click 'Clone to Desktop' button on the right-hand side
4. Open a command prompt and navigate to the location where the Github client cloned the repository (move inside the 'neolib2' folder)

5. Install the required libraries

pip install -r requirements.txt

To test if it's working:

1. Open command prompt/shell and navigate to neolib2 folder
2. Run python3
3. Follow the below prompts

>>> from neolib.user.User import User
>>> usr = User('username', 'password')
>>> usr.login()
True
>>> usr.inventory
Inventory <32 Items>


If you follow the above prompts and get similar results then the library should be in a working order.

j03
11-10-2014, 11:33 PM
@AliasXNeo ([Only registered and activated users can see links]) have you tested this on Linux and/or Mac?

Also if you still need the Random Event code, I have this information. PM me for it.

AliasXNeo
11-10-2014, 11:57 PM
@AliasXNeo ([Only registered and activated users can see links]) have you tested this on Linux and/or Mac?

Also if you still need the Random Event code, I have this information. PM me for it.

I've tested it on an arch linux KVM I use for development and a Mac running a managed version of OSX (managed by Google). However, not much is different than standard OSX so I would assume it works fine. I havn't actually tested the steps I wrote though (which is why I asked for feedback if they don't work).

AliasXNeo
11-12-2014, 05:06 PM
I've added a primer for contributing to the library. It covers most of the internal stuff you need to know about before attempting to contribute.

[Only registered and activated users can see links]

AliasXNeo
11-15-2014, 02:23 AM
Did some major updates today. About 90% of the way to the first stage of beta (only item remaining is main shops). To celebrate I've added an example User Shop Autbuyer script to the repository. Does all the steps of a UAB in less than 25 lines of non-fluff code:



usr = User(username, password)
w = Wizard(usr)

print('Logging in...')
if not usr.login():
print('Login failed! Aborting....')
exit()

print('Initiaing...')
while True:
# Search for the item
print('Searching...')
try:
r = w.search(item, max=max)
except WizardBanned:
print('Shop wizard banned. Aborting...')
exit()

# If we have any results we should buy them all
if r:
print('Found ' + str(len(r)) + ' of ' + item)

bought = r.buy()
if bought:
print('Successfully purchased ' + str(len(bought)) + ' of ' + item)

# Wait some random time for realism
time.sleep(random.randint(5, 10))

AliasXNeo
11-16-2014, 10:23 AM
Updated with support for Main Shops, including an OCR cracker. It now has everything to build a pretty solid MAB.

AliasXNeo
11-18-2014, 11:38 AM
V0.1 Beta has been released. This release now includes a PyPi distribution. This means going forward you no longer need to clone the repository and install manually. Simply:


$ pip3 install neolib2

Or to upgrade to a newer version after installing:


$ pip install neolib2 --upgrade

AliasXNeo
11-20-2014, 12:25 AM
I've added a separate repository for storing applications that use this framework:

[Only registered and activated users can see links]

AliasXNeo
12-03-2014, 11:20 AM
Good news! As part of the cloud integration initiative this library now has a base Docker image hosted on the DockerHub.

This means you can now write Dockerfile's and use this image as the base for deploying your neolib based programs to the cloud in a controlled and easy to monitor manner. I'll update this thread again sometime this week with examples on exactly how to do this.

Repo: [Only registered and activated users can see links]


sudo docker pull jmgilman/neolib2