linkedin_collect_url.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:linkedin_recommend 作者: duggalr2 项目源码 文件源码
def linkedinrec_people(url):
    """ Get's the 10 "People Also Viewed" from a person's url """
    time.sleep(2)
    driver.get(url)
    driver.implicitly_wait(15)
    try:
        wait = WebDriverWait(driver, 15)
        wait.until(EC.presence_of_element_located((By.CLASS_NAME, "right-rail")))
        wait.until(EC.presence_of_element_located((By.TAG_NAME, "ul")))
        wait.until(EC.presence_of_element_located((By.TAG_NAME, "li")))
        a = driver.find_element_by_class_name('right-rail')
        cr = driver.find_element_by_class_name('core-rail')
        yr = cr.find_element_by_tag_name('section')
        xr = yr.find_elements_by_tag_name('div')
        ar = xr[5].text.split('\n')
        sr = ar[0] + ' ' + ar[1]
        y = a.find_element_by_tag_name('ul')
        x = y.find_elements_by_tag_name('li')
        title = [x[i].text.replace('\n', ' ') for i in range(len(x))]
        title.append(sr)
        link = [i.find_element_by_tag_name('a').get_attribute('href') for i in x]
        link.append(url)
        profile_detail = driver.find_element_by_class_name('profile-detail')
        summary = profile_detail.find_elements_by_class_name('pv-entity__summary-info')
        # experience = [i.find_element_by_tag_name('h3').text for i in summary]
        # education = profile_detail.find_element_by_class_name('pv-entity__degree-info').text.split('\n')
        # accomplishment = profile_detail.find_element_by_class_name('pv-accomplishments-block__content')
        # print(accomplishment.text)
        # interest = profile_detail.find_element_by_class_name('pv-deferred-area__content')
        # int_li = interest.find_elements_by_tag_name('li')
        # for i in int_li:
        #     print(i.text)

        # return list(zip(title, link))
    except:
        print('Cannot find it..')
        driver.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号