0
pages = []
for sitemap in sitemaps:
    pages.extend(findall('<loc>(.*)</loc>',
        download(sitemap).decode()))

where,

  1. sitemaps is a list containing the URLs for all sitemap xmls found by parsing a sites robots.txt
  2. call to download takes a url and returns its html as a bytestring.

the code above return a list of URL string, which is intended. turning this into a listcomp like...

pages = [ findall('<loc>(.*)</loc>', download(sitemap).decode() for sitemap in sitemaps ]

...it will return a ragged list (of list of strings)

So, how do can i generate the desired result using listcomps?

gowvia
  • 1
  • 1
  • 1
    Does this answer your question? [How to make a flat list out of a list of lists](https://stackoverflow.com/questions/952914/how-to-make-a-flat-list-out-of-a-list-of-lists) – Mateen Ulhaq Nov 27 '21 at 06:17

0 Answers0