def ieee_author_search_parser(author_name): """ Method to parse the list of publications and their authors from IEEE website into an array object, given the name of the author """ out_file = "data/ieee_author_search.xml" fout = open(out_file, "w") print >> fout, IEEE.ieee_author_search(author_name, kind="xml").encode("utf-8") fout.close() tree = ET.parse(out_file) root_element = tree.getroot() publications = [] for child1 in root_element: if child1.tag == "document": title = None authors = [] publication = {} for child2 in child1: if child2.tag == "title": title = child2.text elif child2.tag == "authors": authors = IEEE_Parser.format_names_list(child2.text) if title is not None: publication["title"] = title publication["authors"] = authors publications.append(publication) return publications
def ieee_author_search_parser(author_name): """ Method to parse the list of publications and their authors from IEEE website into an array object, given the name of the author """ out_file = "data/ieee_author_search.xml" fout = open(out_file, "w") print >> fout, IEEE.ieee_author_search(author_name, kind="xml").encode('utf-8') fout.close() tree = ET.parse(out_file) root_element = tree.getroot() publications = [] for child1 in root_element: if (child1.tag == 'document'): title = None authors = [] publication = {} for child2 in child1: if (child2.tag == 'title'): title = child2.text elif (child2.tag == 'authors'): authors = IEEE_Parser.format_names_list(child2.text) if title is not None: publication['title'] = title publication['authors'] = authors publications.append(publication) return publications
from lookup.IEEE import IEEE import json fout = open("ieee_author_details.txt", "w") def banner(msg): print >> fout, 70 * "=" print >> fout, msg print >> fout, 70 * "=" author = 'Gregor von Laszewski' banner("ieee author details xml") print >> fout, IEEE.ieee_author_search(author, kind="xml").encode('utf-8') banner("ieee author details json") print >> fout, json.dumps(IEEE.ieee_author_search(author, kind="json"), indent=2).encode('utf-8')