Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed handling for when a person has multiple positions under a company #151

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions linkedin_scraper/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,28 @@ def get_experiences(self):
location = ""
else:
position_title = ""
company = outer_positions[0].find_element_by_tag_name("span").find_element_by_tag_name("span").text
company = outer_positions[0].find_element(By.TAG_NAME,"span").find_element(By.TAG_NAME,"span").text
company = company[:company.find("\n")]
work_times = outer_positions[1].find_element_by_tag_name("span").text
location = outer_positions[2].find_element_by_tag_name("span").text
work_times = outer_positions[1].find_element(By.TAG_NAME,"span").text
location = outer_positions[2].find_element(By.TAG_NAME,"span").text
else:
# len(outer_positions) == 2
company = outer_positions[0].find_element_by_tag_name("span").text
work_times = outer_positions[1].find_element_by_tag_name("span").text
company = outer_positions[0].find_element(By.TAG_NAME,"span").text
work_times = outer_positions[1].find_element(By.TAG_NAME,"span").text
position_title = ""
location = ""

if position_summary_text and len(
position_summary_text.find_element_by_class_name("pvs-list").find_element_by_class_name("pvs-list").find_elements_by_xpath("li")) > 1:
descriptions = position_summary_text.find_element_by_class_name("pvs-list").find_element_by_class_name("pvs-list").find_elements_by_xpath("li")
if position_summary_text and len(position_summary_text.find_element(By.CLASS_NAME,"pvs-list").find_element(By.CLASS_NAME,"pvs-list").find_elements(By.XPATH,"li")) > 1:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This element is missing in some profiles i check

descriptions = position_summary_text.find_element(By.CLASS_NAME,"pvs-list").find_element(By.CLASS_NAME,"pvs-list").find_elements(By.XPATH,"li")
for description in descriptions:
res = description.find_element(By.TAG_NAME,"a").find_elements(By.XPATH,"*")
position_title_elem = res[0] if len(res) > 0 else None
work_times_elem = res[1] if len(res) > 1 else None
location_elem = res[2] if len(res) > 2 else None

location = location_elem.find_element_by_xpath("*").text if location_elem else None
position_title = position_title_elem.find_element_by_xpath("*").find_element_by_tag_name("*").text if position_title_elem else ""
work_times = work_times_elem.find_element_by_xpath("*").text if work_times_elem else ""
location = location_elem.find_element(By.XPATH,"*").text if location_elem else None
position_title = position_title_elem.find_element(By.XPATH,"*").find_element(By.TAG_NAME,"*").text if position_title_elem else ""
work_times = work_times_elem.find_element(By.XPATH,"*").text if work_times_elem else ""
times = work_times.split("·")[0].strip() if work_times else ""
duration = work_times.split("·")[1].strip() if len(work_times.split("·")) > 1 else None
from_date = " ".join(times.split(" ")[:2]) if times else ""
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.