Results 1 to 5 of 5

Thread: DTI NC Value Adder

  1. #1
    Atlas's Avatar
    Joined
    Jun 2013
    Posts
    260
    Userbars
    6
    Thanks
    668
    Thanked
    430/149
    DL/UL
    67/8
    Mentioned
    123 times
    Time Online
    27d 4h 44m
    Avg. Time Online
    9m

    DTI NC Value Adder



    (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)

  2. The Following 4 Users Say Thank You to Atlas For This Useful Post:

    Aura (02-21-2016),Daviid (02-22-2016),Guy (02-22-2016),j03 (02-21-2016)

  3. #2

    Joined
    Jul 2012
    Posts
    1,888
    Thanks
    1,619
    Thanked
    3,297/1,003
    DL/UL
    223/0
    Mentioned
    469 times
    Time Online
    132d 23h 52m
    Avg. Time Online
    45m
    @(you need an account to see links) what about using an external NC list?
    Like having a file "myNClist.txt" in the same directory to price those items?

  4. The Following 2 Users Say Thank You to Daviid For This Useful Post:

    Atlas (02-22-2016),Guy (02-22-2016)

  5. #3
    Atlas's Avatar
    Joined
    Jun 2013
    Posts
    260
    Userbars
    6
    Thanks
    668
    Thanked
    430/149
    DL/UL
    67/8
    Mentioned
    123 times
    Time Online
    27d 4h 44m
    Avg. Time Online
    9m
    Quote Originally Posted by Daviid View Post
    @(you need an account to see links) what about using an external NC list?
    Like having a file "myNClist.txt" in the same directory to price those items?
    Sounds like a good idea. I never tried working with TXT files before so this will be interesting!

  6. #4

    Joined
    Jul 2012
    Posts
    1,888
    Thanks
    1,619
    Thanked
    3,297/1,003
    DL/UL
    223/0
    Mentioned
    469 times
    Time Online
    132d 23h 52m
    Avg. Time Online
    45m
    Quote Originally Posted by Atlas View Post
    Sounds like a good idea. I never tried working with TXT files before so this will be interesting!
    Code:
     txtFile = open('./myNClist.txt', 'r')
    data = txtFile.read() #You can do data.split('\n') to get a list of the items
    txtFile.close()
    For plain text files the modes are open(' ', 'r/w/a' )
    r for read
    w for write (will write a new file, will overwrite if file exists)
    a for append (will append to file if exists, if not 'a+' will create file)
    Like this you can forget about closing the file:
    Code:
    with open('./myNClist.txt', 'r') as txtFile:
        data = txtFile.read()
    Last edited by Daviid; 02-22-2016 at 01:18 AM.

  7. The Following User Says Thank You to Daviid For This Useful Post:

    Atlas (02-22-2016)

  8. #5
    Atlas's Avatar
    Joined
    Jun 2013
    Posts
    260
    Userbars
    6
    Thanks
    668
    Thanked
    430/149
    DL/UL
    67/8
    Mentioned
    123 times
    Time Online
    27d 4h 44m
    Avg. Time Online
    9m
    Quote Originally Posted by Daviid View Post
    Code:
     txtFile = open('./myNClist.txt', 'r')
    data = txtFile.read() #You can do data.split('\n') to get a list of the items
    txtFile.close()
    For plain text files the modes are open(' ', 'r/w/a' )
    r for read
    w for write (will write a new file, will overwrite if file exists)
    a for append (will append to file if exists, if not 'a+' will create file)
    Like this you can forget about closing the file:
    Code:
    with open('./myNClist.txt', 'r') as txtFile:
        data = txtFile.read()
    Yikes, I double posted on accident

    And thanks Daviid I'll figure a way how to use that
    I'd also like to add the feature for JN TL/WLs too eventually D:

    It's already so late right now, and I have a pretty busy week, so I'll probably work more on this next weekend!

    And as I leave for tonight, I made a program for @(you need an account to see links) that returns a list of items a pet is wearing according to DTI.
    Code:
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import requests
    
    def clothes(PETNAME):
    
        url = "http://neopia.openneo.net/api/1/pet/customization?utf8=✓&impress_user=&redirect=http%3A%2F%2Fimpress.openneo.net%2Fwardrobe%23%7Bq%7D&name=" + PETNAME
    
        r = requests.get(url, allow_redirects=True)
    
        wearables = r.url.split("&objects%5B%5D=")
        wearables = wearables[1:]
        for i in range(len(wearables)):
            wearables[i] = str(wearables[i][:5])
    
        NAMES = list()
    
        for code in wearables:
            r = requests.get("http://impress.openneo.net/items/" + code)
            name = r.text.split("item-name'>")
            name = name[1]
            name = name.split("<")
            name = name[0]
            name = str(name)
            NAMES.append(name)
    
        print NAMES
    
    
    while True:
        PETNAME = raw_input("""Enter a pet name for their customization: """)
        clothes(PETNAME)
        print
        print
    Thanks again @(you need an account to see links) !!

  9. The Following User Says Thank You to Atlas For This Useful Post:

    Daviid (02-22-2016)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •