How to get the text value of the List?
Source Code:
<ol class="search-results__result-list">
<li class="pv5 ph2 search-results__result-item" data-scroll-into-view="urn:li:fs_salesProfile:(ACwAAAObAYkB4helTgm6WRVfEIIxnY5iuEwkFP4,OUT_OF_NETWORK,uTOK)">
<div class="pt5 absolute z-index-1 search-results__select-container__no-checkbox">
<!----></div>
<div data-test-deferred-did-intersect="" style="">
<div class="search-results__result-container full-width pl2">
<div id="ember244" class="ember-view">
<div id="ember245" class="ember-view">
<article>
<h3 class="a11y-text">
Profile result – Peter Suhosky
</h3>
<section class="result-lockup">
<h4 class="a11y-text">
Profile result lockup – Peter Suhosky
</h4>
<div class="result-lockup__profile-info flex flex-column">
<div class="horizontal-person-entity-lockup-4 result-lockup__entity ml6">
<figure>
<a href="/sales/people/ACwAAAObAYkB4helTgm6WRVfEIIxnY5iuEwkFP4,OUT_OF_NETWORK,uTOK?_ntb=3FrgtPaqRzS8zCtUc%2Bmd6Q%3D%3D" id="ember247" class="ember-view result-lockup__icon-link">
<div class="presence-entity--size-4 relative mr2">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" loading="lazy" alt="Go to Peter Suhosky’s profile" id="ember248" class="max-width max-height circle-entity-4 lazy-image ghost-person ember-view" data-anonymize="headshot-photo">
<div class="presence-indicator presence-indicator--size-4 hidden presence-entity__indicator presence-entity__indicator--size-4" title="Reachable">
Peter Suhosky is reachable
</div>
</div>
</a>
</figure>
<dl>
<dt class="result-lockup__name">
<a href="/sales/people/ACwAAAObAYkB4helTgm6WRVfEIIxnY5iuEwkFP4,OUT_OF_NETWORK,uTOK?_ntb=3FrgtPaqRzS8zCtUc%2Bmd6Q%3D%3D" id="ember250" class="ember-view" data-anonymize="person-name">
Peter Suhosky
</a>
</dt>
<dd class="inline-flex vertical-align-middle">
<ul class="ml1 flex align-items-center list-style-none">
<!----><!----> <li class="mr1 line-height-0">
<div class="no-wrap" data-test-crm-badge="info-everywhere">
<button class="button--unstyled label-16dp color-black6 pv1 ph2 _crm-badge_5gr6fh" aria-disabled="true" data-test-crm-badge="not-in-crm-badge" type="button">
<li-icon aria-hidden="true" type="block-icon" class="color-red vertical-align-text-bottom" size="small"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" data-supported-dps="16x16" fill="currentColor" width="16" height="16" focusable="false">
<path d="M8 1a7 7 0 107 7 7 7 0 00-7-7zm0 1.87a5.09 5.09 0 012.9.9L3.78 10.9A5.12 5.12 0 018 2.87zm0 10.25a5.09 5.09 0 01-2.9-.9l7.12-7.12A5.12 5.12 0 018 13.12z"></path>
</svg></li-icon>
Not in CRM
</button>
</div>
</li>
<!----> </ul>
</dd>
<dd class="result-lockup__highlight-keyword">
Senior Vice President, Financial Advisor, Portfolio Management Director
<span>
at
<span data-entity-hovercard-id="urn:li:fs_salesCompany:497017" class="result-lockup__position-company">
<a href="/sales/company/497017" id="ember252" class="ember-view t-14 t-black--light t-bold">
<span data-anonymize="company-name" aria-hidden="true">
Morgan Stanley
</span>
Go to Morgan Stanley account page
</a>
<button aria-expanded="false" aria-label="See more about Morgan Stanley" class="entity-hovercard__a11y-trigger p0 b0" data-entity-hovercard-id="urn:li:fs_salesCompany:497017" data-entity-hovercard-trigger="click" type="button"></button>
</span>
</span>
</dd>
<dd>
10 years 5 months in role and company
</dd>
<dd>
<ul class="mv1 t-12 t-black--light result-lockup__misc-list">
<li class="result-lockup__misc-item">Greater Scranton Area</li>
</ul>
</dd>
</dl>
</div>
<!----> </div>
<div class="result-lockup__actions flex">
<ul class="result-lockup__common-actions">
<li class="result-lockup__action-item">
<a href="/sales/people/ACwAAAObAYkB4helTgm6WRVfEIIxnY5iuEwkFP4,OUT_OF_NETWORK,uTOK?_ntb=3FrgtPaqRzS8zCtUc%2Bmd6Q%3D%3D" id="ember253" class="ember-view ph4 artdeco-button artdeco-button--secondary artdeco-button--1 artdeco-button--pro
result-lockup__action-button link-without-visited-and-hover-state">
View profile
</a>
</li>
</ul>
</div>
</section>
<section class="result-context relative pt1">
<h4 class="a11y-text">Profile result context – Peter Suhosky</h4>
<!---->
<!---->
<!----> </section>
</article>
<!---->
<!----></div>
</div>
</div>
</div>
</li>
<li class="pv5 ph2 search-results__result-item" data-scroll-into-view="urn:li:fs_salesProfile:(ACwAAAE6lM8B4aO0UQE0kMIyv_Y-K3jJvI_lEMw,OUT_OF_NETWORK,NaYS)">
<div class="pt5 absolute z-index-1 search-results__select-container__no-checkbox">
<!----></div>
<div data-test-deferred-did-intersect="" style="">
<div class="search-results__result-container full-width pl2">
<div id="ember255" class="ember-view">
<div id="ember256" class="ember-view">
<article>
<h3 class="a11y-text">
Profile result – Bartosz P. Bak, CFP®
</h3>
<section class="result-lockup">
<h4 class="a11y-text">
Profile result lockup – Bartosz P. Bak, CFP®
</h4>
<div class="result-lockup__profile-info flex flex-column">
<div class="horizontal-person-entity-lockup-4 result-lockup__entity ml6">
<figure>
<a href="/sales/people/ACwAAAE6lM8B4aO0UQE0kMIyv_Y-K3jJvI_lEMw,OUT_OF_NETWORK,NaYS?_ntb=3FrgtPaqRzS8zCtUc%2Bmd6Q%3D%3D" id="ember258" class="ember-view result-lockup__icon-link">
<div class="presence-entity--size-4 relative mr2">
<img src="https://media-exp1.licdn.com/dms/image/C4E03AQGMr5av02C18A/profile-displayphoto-shrink_100_100/0/1517711779967?e=1646265600&v=beta&t=3pWzGnTp3YBk1REgRrQHludqVPzEohHmgVo63M83FCQ" loading="lazy" alt="Go to Bartosz P. Bak, CFP®’s profile" id="ember259" class="max-width max-height circle-entity-4 lazy-image ember-view" data-anonymize="headshot-photo">
<div class="presence-indicator presence-indicator--size-4 presence-indicator--is-reachable presence-entity__indicator presence-entity__indicator--size-4" title="Last active 8 minutes ago">
Bartosz P. Bak, CFP® was last active 8 minutes ago
</div>
</div>
</a>
</figure>
<dl>
<dt class="result-lockup__name">
<a href="/sales/people/ACwAAAE6lM8B4aO0UQE0kMIyv_Y-K3jJvI_lEMw,OUT_OF_NETWORK,NaYS?_ntb=3FrgtPaqRzS8zCtUc%2Bmd6Q%3D%3D" id="ember261" class="ember-view" data-anonymize="person-name">
Bartosz P. Bak, CFP®
</a>
</dt>
<dd class="inline-flex vertical-align-middle">
<ul class="ml1 flex align-items-center list-style-none">
<!----><!----> <li class="mr1 line-height-0">
<div class="no-wrap" data-test-crm-badge="info-everywhere">
<button class="button--unstyled label-16dp color-black6 pv1 ph2 _crm-badge_5gr6fh" aria-disabled="true" data-test-crm-badge="not-in-crm-badge" type="button">
<li-icon aria-hidden="true" type="block-icon" class="color-red vertical-align-text-bottom" size="small"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" data-supported-dps="16x16" fill="currentColor" width="16" height="16" focusable="false">
<path d="M8 1a7 7 0 107 7 7 7 0 00-7-7zm0 1.87a5.09 5.09 0 012.9.9L3.78 10.9A5.12 5.12 0 018 2.87zm0 10.25a5.09 5.09 0 01-2.9-.9l7.12-7.12A5.12 5.12 0 018 13.12z"></path>
</svg></li-icon>
Not in CRM
</button>
</div>
</li>
<!----> </ul>
</dd>
What I have tried:
try:
def GetName():
page_source = BeautifulSoup(driver.page_source, 'html.parser')
porfilesName = page_source.find('ol', class_='search-results__result-list').find_all('li', class_='pv5 ph2 search-results__result-item')
all_profile_Name = []
for profile in porfilesName:
if profile not in all_profile_Name:
all_profile_Name.append(profile)
getdata = str(all_profile_Name)
print(getdata)
return all_profile_Name
print (GetName())
except Exception as e:
print(e)