Trying to write a program that extracts URLs from a website. The output is good, but when I try to write the output to a file, only the last record is written. Here is the code:
You need to open you file then Write each X in the for loop.
At the end you can close the file.
f = open("f2.txt", "w+",1) for x in extractUrls(url): print("-", x) f.write( x ) f.close()