<commit_before>from urllib import urlopen # to open the RSS feeds

def xml_to_string(xml_link):
    # http://docs.python.org/2/library/urllib2.html
    # Section 20.6.21 is especially helpful
    return urlopen(xml_link).read()

xml_link = 'http://www.nlrb.gov/rss/rssBoardDecisions.xml'
xml_text = xml_to_string(xml_link)

<commit_msg>Extract XML from Board Decision<commit_after>from urllib import urlopen # to open the RSS feeds
import xml.etree.ElementTree as ET # to parse XML

def get_case_info(item):
    # Extracts info out of XML document

    case_info = {}
    case_info['title'] = item.find('title').text
    description = item.find('description').text    
    case_info['description'] = description
    dash_pos = description.find(" - ")
    case_num = description[:dash_pos].strip()
    case_info['case_num'] = case_num
    case_info['case_type'] = case_num[3:5]
    case_info['nlrb_region'] = case_num[0:2]
    case_info['involved_party'] = description[dash_pos+3:]
    case_info['pub_date'] = item.find('pubDate').text
    case_info['pdf_link'] = item.find('guid').text
    
    return case_info
    
def xml_to_string(xml_link):
    # http://docs.python.org/2/library/urllib2.html
    # Section 20.6.21 is especially helpful
    return urlopen(xml_link).read()

xml_link = 'http://www.nlrb.gov/rss/rssBoardDecisions.xml'
xml_text = xml_to_string(xml_link)
root = ET.fromstring(xml_text)

for item in root.iter('item'):
    print get_case_info(item)
{'fraction_non_alphanumeric': 0.12901023890784982, 'fraction_numerical': 0.012969283276450512, 'mean_word_length': 4.198581560283688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 18}, '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': '5345365', 'n_tokens_mistral': 520, 'n_tokens_neox': 505, 'n_words': 98}