I am trying to get the URL list, not a True
of False
response at the end of the statement.
#!/usr/bin/env python
import requests
from BeautifulSoup import BeautifulSoup
url ="https://www.geant.tn/"
response = requests.get(url)
# parse html
page = str(BeautifulSoup(response.content))
def getURL(page):
No problem for this part
"""
: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_quote
while True:
url, n = getURL(page)
page = page[n:]
I am having a problem here, as I am getting True
or False
displayed:
if url.endswith('.html'):
print url
else:
break
If you can help me, thanks a lot!