相关疑难解决方法(0)

IMDB是否提供API?

我最近发现了一个电影管理器应用程序,它从IMDB数据库中获取数据.

IMDB是否为此提供API,或者是否提供任何第三方API?

imdb asp.net-web-api

631
推荐指数
10
解决办法
43万
查看次数

如何从请求响应中提取HTTP错误文本?

我有以下代码:

    tries = 10
    for n in range(tries):
        try:
            ....
            responsedata = requests.get(url, data=data, headers=self.hed, verify=False)
            responsedata.raise_for_status()
            ..
            if .... : 
                break   #exit loop condition

        except (ChunkedEncodingError, requests.exceptions.HTTPError) as e:
            print ("page #{0} run #{1} failed. Returned status code {2}. Msg: {3}. Retry.".format(page, n, responsedata.status_code, sys.exc_info()[0]))
            if n == tries - 1:
               raise e  # exit the process
Run Code Online (Sandbox Code Playgroud)

我看到的照片是:

page #53 run #0 failed. Returned status code 502. Msg: <class 'requests.exceptions.HTTPError'>. Retry.
page #1 run #1 failed. Returned status code …
Run Code Online (Sandbox Code Playgroud)

python python-requests

3
推荐指数
2
解决办法
2763
查看次数

标签 统计

asp.net-web-api ×1

imdb ×1

python ×1

python-requests ×1