• This News Doesn't Suck!

    Everyone stop what you're doing! It's happening! GW's own Alu is having a baby!! Come and congratulate him here: Need some help identifying this picture.

    We're so happy for you, Alu!

Resolved API?

Status
Not open for further replies.

Ben

ლ(ಠ益ಠლ)
Administrator
Dadministrator
Moderator
Executive
GWF Sponsor
GW Elder
Wolf Players
Messages
9,043
Hmm. Well we'd have to see if @Ben managed to refine his project further, that might be w hat's needed?
Nope, I haven't unfortunately. I didn't have time to do the actual data entry to track the old games, so I put it aside for now.

Really anyone can export a thread the same way I was. Crystal hooked me up with https://gwforums.com/converter/ to get a csv of thread contents, but it had limits to not working on huge threads and I don't think those were resolved.

There no actual API to dynamically make connections to the database, though. Just manual exports.
 
Messages
5,333
Wanted to use it to do the scripting for checking animals in the mafia thread. Ended up just saving the pages sources for the thread as a text file and then using python to parse it. @Tommy Boy seemed interested, so here:


Python:
file = open("Animals.txt","r")
data = file.read().replace("Â\xa0","")
animals = data.replace('\n','.').split(".")

phrase = "data-lb-caption-desc"
phrase2 = '<div class="bbWrapper">'
phrase3 = '<footer class="message-footer">'

text = open("Day1Page1.txt", encoding="utf8")
text1 = text.read()

temp = text1
breaks = []
posters = []
posts = []
text_break=0

while (temp.find(phrase, text_break+1) > 0):
    text_break = temp.find(phrase, text_break+1)
    breaks.append(text_break)
    posters.append(text1[text_break+22:text_break+22+text1[text_break+22:].find(" &middot")])

total = len(breaks)

for j in range(total):
    if j == total-1:
        temp = text1[breaks[j]:]
        temp = temp[:temp.find(phrase3)]
    else:
        temp = text1[breaks[j]:breaks[j+1]]
        temp = temp[:temp.find(phrase3)]
    const=1
    const2=0
    word = ""
    for i in temp:
        if i=="<":
            const = 1
        if const == 0 and i=="&":
            const2 = 1
        if const == 0 and const2 == 0 and i !='\t':
            word = word + i
        if const == 0 and i==";" and const2==1:
            const2 = 0
        if i==">":
            const=0
    posts.append(word.replace('\n',' ').replace("."," ").replace("?"," ").replace(","," ").replace('"'," ").upper())

for k in range(len(posts)):
    count = 0
    words = posts[k].split(' ')
    for l in animals:
        if l.upper() in words:
            count = count + 1
    print(posters[k] + ": " + str(count))
 
Status
Not open for further replies.
Back
Top Bottom