鍍金池/ 問答/數(shù)據(jù)分析&挖掘  Python  HTML/ 用python 遞歸式獲取 http請求 的 response

用python 遞歸式獲取 http請求 的 response

我現(xiàn)在想要用Python 遞歸式的獲取 網(wǎng)頁信息:

  1. 網(wǎng)頁信息非常簡單, 當我請求 url_one時,我會得到一個 list,例如

    [

    {
        'url':'url_1',
        'isEnd': 'no'
    },
    {
        'url': 'url_2',
        'isEnd': 'yes'
    }

    ]

  2. 如果 isEnd 為 no, 那么我就繼續(xù) 請求 這個url,直到 某個 url 的 isEnd 為yes.

請問如何實現(xiàn)?

回答
編輯回答
朽鹿

這有啥需要遞歸的, 一個for 加個if 判斷不就完事了。。。 或者你的想法沒有表達清楚?

字典取值
···python
for i in list:

if i["isEnd"] == no:
    request
else:
    break

···

2018年6月10日 02:08