Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added a parser for a Profile skills "

  • Loading branch information...
commit 775fd061e4f243ae37b4aa1e3b3e6e39c3dacff8 1 parent 34e0f7e
philgo20 authored
Showing with 41 additions and 4 deletions.
  1. +25 −1 liclient/parsers/lixml.py
  2. +16 −3 liclient/parsers/mappers.py
View
26 liclient/parsers/lixml.py
@@ -11,7 +11,8 @@ def __init__(self, content):
'update-comments': self.__parse_update_comments,
'connections': self.__parse_connections,
'error': self.__parse_error,
- 'position': self.__parse_position,
+ 'position': self.__parse_position,
+ 'skill': self.__parse_skills,
'education': self.__parse_education,
'people': self.__parse_people_collection,
'twitter-account': self.__parse_twitter_accounts,
@@ -39,6 +40,10 @@ def __parse_update_comments(self, tree):
def __parse_connections(self, tree):
content = LinkedInConnectionsParser(tree).results
+ return content
+
+ def __parse_skills(self, tree):
+ content = LinkedInSkillsParser(tree).results
return content
def __parse_error(self, tree):
@@ -320,4 +325,23 @@ def __build_data(self, tree):
results = mappers.MemberUrlResource(data, tree)
return results
+class LinkedInSkillsParser(LinkedInXMLParser):
+ def __init__(self, content):
+ self.tree = content
+ self.xpath_collection = {
+ 'id': etree.XPath('id'),
+ 'name': etree.XPath('skill/name'),
+ }
+ self.results = self.__build_data(self.tree)
+
+ def __build_data(self, tree):
+ data = {}
+ for n in tree.getchildren():
+ if not n.getchildren():
+ data[re.sub('-', '_', n.tag)] = n.text
+ else:
+ data[re.sub('-', '_', n.tag)] = n.getchildren()[0].text
+ results = mappers.Skills(data, tree)
+ return results
+
View
19 liclient/parsers/mappers.py
@@ -218,14 +218,16 @@ def __init__(self, data, xml):
self.profile_url = ''
self.xml = xml
self.parse_data(data)
- self.positions = []
+ self.positions = []
+ self.skills = []
self.educations = []
self.twitter_accounts = []
self.member_url_resources = []
if not self.profile_url:
self.set_profile_url()
self.get_location()
- self.get_positions()
+ self.get_positions()
+ self.get_skills()
self.get_educations()
self.get_twitter_accounts()
self.get_member_url_resources()
@@ -251,7 +253,15 @@ def get_positions(self):
pos = profile_position_xpath(self.xml)
for p in pos:
obj = lixml.LinkedInXMLParser(etree.tostring(p)).results
- self.positions.append(obj)
+ self.positions.append(obj)
+
+ def get_skills(self):
+
+ profile_skills_xpath = etree.XPath('skills/skill')
+ skills = profile_skills_xpath(self.xml)
+ for s in skills:
+ obj = lixml.LinkedInXMLParser(etree.tostring(s)).results
+ self.skills.append(obj)
def get_educations(self):
profile_education_xpath = etree.XPath('educations/education')
@@ -284,6 +294,9 @@ class Education(LinkedInData):
class TwitterAccount(LinkedInData):
pass
+
+class Skills(LinkedInData):
+ pass
class MemberUrlResource(LinkedInData):
pass
Please sign in to comment.
Something went wrong with that request. Please try again.