Skip to content

Instantly share code, notes, and snippets.

@coreyhermanson
Created June 30, 2016 16:22
Show Gist options
  • Save coreyhermanson/c053f0416d9cc166d41f06c3891232dc to your computer and use it in GitHub Desktop.
Save coreyhermanson/c053f0416d9cc166d41f06c3891232dc to your computer and use it in GitHub Desktop.
Python script to generate search result page URLs
#!/usr/bin/env python
import pyperclip
import sys
"""
Example output for below configuration, pasted to your Clipboard:
http://www.exampledomain.com/all-stories/?page=1
http://www.exampledomain.com/all-stories/?page=2
http://www.exampledomain.com/all-stories/?page=3
http://www.exampledomain.com/all-stories/?page=4
"""
rangeNum = 4
domain_path = 'http://www.exampledomain.com/all-stories/?page='
concatUrl = []
try:
# concatenate URLs based on domain_path and nums from 1-rangeNum
for num in range(1, (rangeNum + 1)):
concatUrl.append(domain_path + str(num))
# concatUrl.append(domain_path + str(num) + '&category=audit-accounting')
# Copy the results list to the Clipboard
if len(concatUrl) > 0:
pyperclip.copy('\n'.join(concatUrl))
print("Copied to clipboard")
else:
print("There was nothing on the clipboard")
except:
print("Unexpected error:", sys.exc_info()[0])
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment