Skip to content

Instantly share code, notes, and snippets.

@autosquid
Last active October 26, 2015 06:11
Show Gist options
  • Save autosquid/423b5d03bfc70f56d04d to your computer and use it in GitHub Desktop.
Save autosquid/423b5d03bfc70f56d04d to your computer and use it in GitHub Desktop.
python script for batch opening urls and searching with keywords
def slowopen(fname):
with open(fname, 'r') as f:
for url in f:
# url = slowopen_ieee(url)
if platform.system() == 'Darwin':
os.system(" ".join(["open -a Safari", url]))
#os.system(" ".join(["open", url]))
else:
os.system(" ".join(["start", url]))
time.sleep(5)
def sortfile(srcfile, dstfile):
urls = []
with open(srcfile, 'r') as f:
for url in f:
urls.append(url)
sortedurls = sorted(urls)
with open(dstfile, 'w') as f:
f.write('\n'.join(sortedurls))
def slowsearch(fname):
with open(fname, 'r') as f:
for item in f:
# item = slowopen_ieee(item)
item = 'http://search.aol.com/aol/search?q=' + '+'.join(item.split(' '))
if platform.system() == 'Darwin':
#os.system(" ".join(["open -a Safari", item]))
os.system(" ".join(["open", item]))
else:
os.system(" ".join(["start", item]))
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment