我想获得的URL列表,而不是一个True的False在声明的最后答复。#!/usr/bin/env pythonimport requestsfrom BeautifulSoup import BeautifulSoupurl ="https://www.geant.tn/"response = requests.get(url)# parse htmlpage = str(BeautifulSoup(response.content))def getURL(page):这部分没问题 """ :param page: html of web page (here: Python home page) :return: urls in that page """ start_link = page.find("a href") if start_link == -1: return None, 0 start_quote = page.find('"', start_link) end_quote = page.find('"', start_quote + 1) url = page[start_quote + 1: end_quote] return url, end_quotewhile True: url, n = getURL(page) page = page[n:]我在这里遇到问题,因为我得到True或False显示:if url.endswith('.html'): print urlelse: break如果你能帮助我,非常感谢!
添加回答
举报
0/150
提交
取消