for el in elem:
urls=(re.findall(re.compile('((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?
\+-=\\\.&](#!)?)*)',re.DOTALL), el.text))
for lnk in urls:
print(lnk[0])
output: https://Instagram.com/datravelvibes https://i.imgur.com/s7YM0qH.png
This is a program to extract the URL from the text. I am able to do the extraction and print the URLs but not able to open these links in a new tab in this program, when I type this driver.execute_script("window.open('lnk[0]','newtab)")
in place of print(lnk[0])