scrape_page.py 文件源码

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

项目:ebay 作者: fgscivittaro 项目源码 文件源码
def get_soup(url, num_retries = 10):
    """
    Takes in a url and returns the parsed BeautifulSoup code for that url with
    handling capabilities if the request 'bounces'.
    """

    s = requests.Session()

    retries = Retry(
        total = num_retries,
        backoff_factor = 0.1,
        status_forcelist = [500, 502, 503, 504]
        )

    s.mount('http://', HTTPAdapter(max_retries = retries))

    return BeautifulSoup(s.get(url).text, 'html.parser')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号