I'm trying to parse an online text file's contents then extract all URLs. Everything works fine except the URL extraction part. It doesn't happen. I tried the same process on a local file, and it worked. What is wrong?
COMMAND
import requests
import re
from io import StringIO
link = "https://pastebin.com/raw/B8QauiXU"
urls = requests.get(link)
with open(urls.text) as file, io.StringIO() as output:
for line in file:
urls = re.findall('https?://[^\s<>"]+[|www\.^\s<>"]+', line)
print(*urls, file=output)
urls = output.getvalue()
print(urls)
OUTPUT
https://google.com and https://bing.com are both the two largest search engines in the world. They are followed by https://duckduckgo.com.