how to output "print(urls)" into new file.txt
with open("path\url_example.txt") as file:
for line in file:
urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', line)
print(urls)
how to output "print(urls)" into new file.txt
with open("path\url_example.txt") as file:
for line in file:
urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', line)
print(urls)
Code:
input_file_path = "/home/home/filessssss/example.txt"
# Output file path
output_file_path = "file.txt"
with open(input_file_path) as file:
with open(output_file_path, "w") as output_file:
for line in file:
urls = re.findall('https?://(?:[-\w.]|(?:%\da-fA-F{2}))+', line)
for url in urls:
output_file.write(url + "\n")