I did a lot of programming about 6 years ago when my username was known a lot more (I've made at least one of every popular program type, including a premium MAB I sold). I have since returned to the programming scene for another bout
I don't really have much to brag with since it's all long gone. However, here's some sample code of the latest version of the library (0.2):
Code:
from neolib.user.User import User
from neolib.daily.Daily import Daily
usr = User("username", "password")
if usr.login(): print "Logged in!"
list = ['Tombola', 'FruitMachine', 'PetPetPark']
for message in Daily.doDailies(usr, list):
print message
print "All dailies done!"
That's an example of the user end. For the developer end, here's a sample:
Code:
def __init__(self, usr):
if not usr:
raise invalidUser
self.items = {}
pg = usr.getPage("http://www.neopets.com/objects.phtml?type=inventory")
# Indicates an empty inventory
if pg.content.find("You aren't carrying anything") != -1:
return
try:
for row in pg.find_all("td", "contentModuleContent")[1].table.find_all("tr"):
for item in row.find_all("td"):
name = item.text
# Some item names contain extra information encapsulated in paranthesis
if name.find("(") != -1:
name = name.split("(")[0]
tmpItem = Item(name)
tmpItem.id = item.a['onclick'].split("(")[1].replace(");", "")
tmpItem.img = item.img['src']
tmpItem.desc = item.img['alt']
tmpItem.usr = usr
self.items[name] = tmpItem
except Exception:
logging.getLogger("neolib.inventory").exception("Unable to parse user inventory.")
logging.getLogger("neolib.html").info("Unable to parse user inventory.", {'pg': pg})
raise parseException
That's the code for the UserInventory class __init__() method.