Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from webdriver_manager.chrome import ChromeDriverManager
- from bs4 import BeautifulSoup
- from selenium.webdriver.common.by import By
- import time
- URL = "https://www.morganlewis.com/our-people"
- HOST = "https://www.morganlewis.com"
- def get_driver():
- driver = webdriver.Chrome(ChromeDriverManager().install())
- return driver
- driver = get_driver()
- driver.get(URL)
- time.sleep(6)
- html = driver.page_source
- soup = BeautifulSoup(html, 'html.parser')
- items = soup.find_all('div', class_='c-content-team__card')
- url_list = []
- for item in items:
- url_profile = HOST + item.find('a', href=True).get('href')
- url_list.append(url_profile)
- bio_info = []
- for url in url_list:
- driver.get(url)
- img = driver.find_elements_by_class_name('thumbnail')
- for i in img:
- bio_info.append(i.find_element_by_tag_name('img').get_attribute('src'))
- phone_numbers = driver.find_elements_by_class_name('underline')
- for i in phone_numbers:
- bio_info.append(i.find_element_by_tag_name('a').get_attribute('href'))
- name = driver.find_elements_by_tag_name('h1')
- for i in name:
- bio_info.append(i.text)
- email = driver.find_elements_by_id('bio-mail-id')
- for i in email:
- bio_info.append(i.find_elements_by_tag_name('a').get_attribute('href'))
- sectors = driver.find_elements_by_class_name('person-depart-info')
- for i in sectors:
- bio_info.append(i.find_element_by_tag_name('a').get_attribute('title'))
- sector = driver.find_elements_by_class_name('collapse-expand-cont bio-accordion-listing')
- for i in sector:
- bio_info.append(i.find_element_by_tag_name('a').get_attribute('title'))
- publication = driver.find_elements_by_class_name('block print-Publication')
- for i in publication:
- elem = i.find_elements_by_class_name('collapse-expand-cont bio-accordion-listing')
- bio_info.append(elem.find_elements_by_tag_name('a').get_attribute('href'))
- print(bio_info)
Advertisement
Add Comment
Please, Sign In to add comment