Hi 大家好
有一個迴圈的問題想請問大家
該怎麼寫 while 迴圈 這以下的code 只 run 10次呢?
目前鬼打牆 一直寫不出來 ...
def GoNextPage(old_url):
GetNext20Records("Next 20 Records")
url = browser.current_url
if old_url == url:
return
html = GetHtml(url)
url_lst = GetUrl(html)
for url in url_lst[:]:
url = root_url + url
url = url.replace(' ', '%20')
GetFile(url)
GoNextPage(url)
先謝謝大家了!!
再次感謝大家的幫忙,修改一點P大的code使我整個程式可以run,
在這邊分享:
def GoNextPage(number_of_pages):
if number_of_pages > 0:
GetNext20Records("Next 20 Records")
url = browser.current_url
html = GetHtml(url)
url_lst = GetUrl(html)
for url in url_lst[:]:
url = root_url + url
url = url.replace(' ', '%20')
GetFile(url)
GoNextPage(number_of_pages-1)
else:
return
#running pages
number_of_pages = 4
GoNextPage(number_of_pages)