(you need an account to see links)
Requirements You will need to have httplib2 and BeautifulSoup libraries;
If you have pip, run the following lines in terminal to install:
Code:
pip install httplib2
Code:
pip install beautifulsoup
Instructions Just replace the DTI closet link with your DTI closet link, and run the program to
return a total of the TL/WL items using the lowest value listed off of /~Clara .
To-do txt file lists; suggestions?
Open-source *current as of Feb 22, 11:30pm NST*
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
from bs4 import BeautifulSoup, SoupStrainer
import httplib2
################################################################################################
DTI_link = "https://impress.openneo.net/user/00000-username/closet" # your DTI closet link
################################################################################################
print "Making checklists from DTI list..."
print
print
http = httplib2.Http()
status, response = http.request(DTI_link)
response = response.split("<h3>")
trade_list = response[1]
wish_list = response[2]
CHECKLIST_TRADE = list()
for a in BeautifulSoup(trade_list, "html.parser", parse_only=SoupStrainer("a")):
check_item = str(a.text.replace("\n",""))
CHECKLIST_TRADE.append(check_item)
CHECKLIST_WISH = list()
for a in BeautifulSoup(wish_list, "html.parser", parse_only=SoupStrainer("a")):
check_item = str(a.text.replace("\n",""))
CHECKLIST_WISH.append(check_item)
CHECKLIST_WISH = CHECKLIST_WISH[:-8]
print "Tradelist is a total of %s items..." % len(CHECKLIST_TRADE)
print "Wishlist is a total of %s items..." % len(CHECKLIST_WISH)
print
print
print "Retrieving live values from /~clara..."
print
print
source = urllib.urlopen("http://www.neopets.com/~clara")
page = source.readlines()
ITEMS = list()
VALUES = list()
for line in page:
if "~" in line:
line = line.replace("<br>\r\n","")
line = line.split("~")
line[0] = line[0].split("<")[0]
line[0] = line[0].strip()
line[0] = line[0].replace("�","e")
line[0] = line[0].replace("š","s")
line[0] = line[0].replace("�","a")
line[0] = line[0].replace("�","u")
line[1] = line[1].split("-")[0]
line[1] = line[1].split("+")[0]
line[1] = line[1].split("<")[0]
line[1] = line[1].split(" ")[0]
try:
line[1] = int(line[1])
ITEMS.append(line[0])
VALUES.append(line[1])
except:
pass
ITEMS.pop(-1)
VALUES.pop(-1)
PAIRS = dict()
for i in range(len(ITEMS)):
PAIRS[ITEMS[i]] = VALUES[i]
print "Summing up values...for tradelist..."
print
print
trade_totals = 0
trade_expensive = None
for item in CHECKLIST_TRADE:
try:
trade_totals += PAIRS[item]
if PAIRS[item] > trade_expensive:
trade_expensive, trade_expensive_item = PAIRS[item], item
except:
print "Couldn't find value for %s..." % item
print
print "Summing up values...for wishlist..."
print
print
wish_totals = 0
wish_expensive = None
for item in CHECKLIST_WISH:
try:
wish_totals += PAIRS[item]
if PAIRS[item] > wish_expensive:
wish_expensive, wish_expensive_item = PAIRS[item], item
except:
print "Couldn't find value for %s..." % item
print
print
print "The total (lowest) value of all searchable TL items add up to %s." % trade_totals
print "The total (lowest) value of all searchable WL items add up to %s." % wish_totals
print
print "The most expensive TL item is %s, valued at %s." % (trade_expensive_item, trade_expensive)
print "The most expensive WL item is %s, valued at %s." % (wish_expensive_item, wish_expensive)