linkedin_parser.py 文件源码

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

项目:linkedin_recommend 作者: duggalr2 项目源码 文件源码
def get_people_viewed(self, url):
        """
        Parses's the Person's Name + Header and also parse's the 10 "People Also Viewed" from a person's url
        Returns list of tuples with (Name + Header, url)
        If people also viewed option not available, list will just be len(1)
        (Rarely, Selenium doesn't pick up the JS DOM, so the script tries 2 more times before raising an exception)
        """
        self.driver.get(url)
        # count = 0
        try:
            wait = WebDriverWait(self.driver, 20)
            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 = self.driver.find_element_by_class_name('right-rail')
            cr = self.driver.find_element_by_class_name('core-rail')
            y = a.find_element_by_tag_name('ul')
            x = y.find_elements_by_tag_name('li')
            link = [i.find_element_by_tag_name('a').get_attribute('href') for i in x]
            link.append(url)
            return link
        except:
            raise Exception('Tried and Cannot find it..')
            # self.driver.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号