This is does the following:
1. Opens Notepad ( Yes this script runs only on windows ). You should paste the text and save it.
2. This Uses regular expression to search websites name form text.
3. Then all websites are open simultaneously on the DEFAULT web browser in separate tabs.
import webbrowser
import string
import subprocess
import fileinput
import sys
import re
open('sites.txt', 'w').close()
subprocess.call(['notepad.exe', 'sites.txt'])
for line in fileinput.input('sites.txt', inplace=True):
line = line.replace("\n", " ")
sys.stdout.write(line)
f = open('sites.txt')
text1 = f.read()
f.close()
#print(text1)
websites = re.findall(r'(\S+[.]com)', text1) # this is the RE
#print(websites)
data = ', '.join(websites)
#print(data)
data1 = data.replace(",", "")
#print(data1)
words = data1.split()
for word in words:
url = 'http://' + word
print(url)
webbrowser.open(url)
1. Opens Notepad ( Yes this script runs only on windows ). You should paste the text and save it.
2. This Uses regular expression to search websites name form text.
3. Then all websites are open simultaneously on the DEFAULT web browser in separate tabs.
import webbrowser
import string
import subprocess
import fileinput
import sys
import re
open('sites.txt', 'w').close()
subprocess.call(['notepad.exe', 'sites.txt'])
for line in fileinput.input('sites.txt', inplace=True):
line = line.replace("\n", " ")
sys.stdout.write(line)
f = open('sites.txt')
text1 = f.read()
f.close()
#print(text1)
websites = re.findall(r'(\S+[.]com)', text1) # this is the RE
#print(websites)
data = ', '.join(websites)
#print(data)
data1 = data.replace(",", "")
#print(data1)
words = data1.split()
for word in words:
url = 'http://' + word
print(url)
webbrowser.open(url)
Comments
Post a Comment