• Celebrating One Year of Revival!

    Come and join us in celebrating one year of GW's revival as GWF, share in some statistics and help us push towards the next twenty years! CLICK HERE

    We're also looking for suggestions for another community event we can put together that we can all enjoy! Come and give us some suggestions HERE
  • Our second year of the NFL Pick 'Em is open to join now. You can join directly here and get involved in the weekly threads over in the Picks forum.
  • If you are reading this message, congratulations! You are on the new server! You made it!!

Resolved API?

Status
Not open for further replies.

Ben

Blind Guardian
Executive
Moderator
GWF Sponsor
Administrator
Badministrator
GW Elder
Messages
6,419
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.
 
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