Ramazan
Regular Member
- Aug 19, 2018
- 433
- 308
Hello i have 2 functions and the names are sitemap and title I'm catching sitemap URL's on that function and with that URL going for the title function but I can't reach
for websiteurls in xml_urls:
return websiteurls
loop. That's my problem how can I reach that for loop?
for websiteurls in xml_urls:
return websiteurls
loop. That's my problem how can I reach that for loop?
Python:
def sitemap():
url = 'https://url.com/sitemap.xml'
sitemaprequest = requests.get(url)
sitemapcontent = sitemaprequest.content
sitemapsoup = BeautifulSoup(sitemapcontent,'lxml')
sitemapurls = sitemapsoup.find_all("loc")
xml_urls = []
for sitemapurl in sitemapurls:
xml_urls.append(sitemapurl.text)
for websiteurls in xml_urls:
return websiteurls
def title():
for urlstitle in websiteurls:
titlerequest = request.get(websiteurls)
titlerequest.text
titlesource = BeautifulSoup(titlerequest.text, 'html.parser')
for titles in titlesource.find_all('title'):
title = titles.get_text()
return title