Created
June 30, 2016 16:22
-
-
Save coreyhermanson/c053f0416d9cc166d41f06c3891232dc to your computer and use it in GitHub Desktop.
Python script to generate search result page URLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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