unshortenit.py 文件源码

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

项目:pelisalacarta-ce 作者: pelisalacarta-ce 项目源码 文件源码
def _unshorten_linkbucks(self, uri):
        try:
            with closing(PhantomJS(
                    service_log_path=os.path.dirname(os.path.realpath(__file__)) + '/ghostdriver.log')) as browser:
                browser.get(uri)

                # wait 5 seconds
                time.sleep(5)

                page_source = browser.page_source

                link = re.findall(r'skiplink(.*?)\>', page_source)
                if link is not None:
                    link = re.sub(r'\shref\=|\"', '', link[0])
                    if link == '':
                        return uri, 'Failed to extract link.'
                    return link, 200
                else:
                    return uri, 'Failed to extract link.'

        except Exception as e:
            return uri, str(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号