<commit_before>import requests
import manage
from manage import session
from fight_simulator import database, config, __init__, views
from fight_simulator.database import User, Fighter, History

import urllib
from urllib.request import urlopen
import xml.etree.ElementTree as etree

response = urllib.request.urlopen("http://api.spike.com/feeds/bellator/1.0/fighters?key=BELLATORAPPKEY&numberOfItems=200&pageNumber=1")
tree = etree.parse(response)
for each in tree:
    print(each)
root = tree.getroot()
for branch in root:
    print(branch)
<commit_msg>scraper works, now adds Bellator fighters to DB. no fighter images at the moment<commit_after>import requests
import manage
import untangle
from manage import session
from fight_simulator import database, config, __init__, views
from fight_simulator.database import Fighter

xml = "http://api.spike.com/feeds/bellator/1.0/fighters?key=BELLATORAPPKEY&numberOfItems=188&pageNumber=1"

bellator_f = untangle.parse(xml)
fighters = bellator_f.fighters.fighter

for fighter in fighters:
    if fighter.firstName != "To Be Announced":
        record = fighter.record.cdata
        win = record.split('-')[0]
        loss = record.split('-')[1]
        draw = record.split('-')[2]
        if fighter.sex.cdata == 'W':
            gender = 'female'
        else:
            gender = 'male'
        fweight = float(fighter.weight.cdata)
        if fweight <= 126:
            weight = "Flyweight"
        if 127 <= fweight <= 136:
            weight = "Bantamweight"
        if 137 <= fweight <= 146:
            weight = "Featherweight"
        if 147 <= fweight <= 156:
            weight = "Lightweight"
        if 157 <= fweight <= 171:
            weight = "Welterweight"
        if 172 <= fweight <= 186:
            weight = "Middleweight"
        if 187 <= fweight <= 206:
            weight = "Light Heavyweight"
        if 207 <= fweight:
            weight = "Heavyweight"
        fighter = Fighter(
            first_name = fighter.firstName.cdata,
            last_name = fighter.lastName.cdata,
            gender = gender,
            promotion = "Bellator",
            weight = weight,
            win = win,
            loss = loss,
            draw = draw,
            )
        session.add(fighter)
session.commit()

{'fraction_non_alphanumeric': 0.10127137220517317, 'fraction_numerical': 0.02498903989478299, 'mean_word_length': 2.4575757575757575, 'pattern_counts': {'":': 1, '<': 17, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3902978', 'n_tokens_mistral': 726, 'n_tokens_neox': 666, 'n_words': 181}