Skip to content

Instantly share code, notes, and snippets.

@dashw00d
Created February 13, 2019 21:21
Show Gist options
  • Save dashw00d/fd5eccaf24df01a56442db21882cb157 to your computer and use it in GitHub Desktop.
Save dashw00d/fd5eccaf24df01a56442db21882cb157 to your computer and use it in GitHub Desktop.
#! /usr/local/bin/python3
# -*- coding: utf-8-sig -*-
import os
import csv
import pyperclip
bpath = "C:/Program\ Files\ (x86)/Google/Chrome/Application/chrome.exe"
output_file = './output/monitization_results.csv'
options = {
"Amazon Alexa": "[amazon_link asins='B0792KTHKJ,B0794W1SKP,B077SXWSRP' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='25c3517d-1dae-4071-9291-2f3fd772a609']",
"Smart Door Locks": "[amazon_link asins='B00AGK9KOG,B00YUPDW0Q,B0752VPHVK' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='acd88415-2285-49cb-9707-eb1e7616d015']",
"Smoke": "[amazon_link asins='B00PC5SPPK,B00O8MVW12,B07BY1968J' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='8f640bc3-cade-4868-a3ca-3c0b14441be7']",
"Security Cameras": "[amazon_link asins='B071YPNMN1,B01CW4CEMS,B01IT8LO1I' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='b76194f6-6f88-4556-aa04-49a406f066b5']",
"Doorbell Cameras": "[amazon_link asins='B00N2ZDXW2,B06XZWHBJ4,B01DM6BDA4' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='9469d459-ce82-4a60-b8b5-94c4520d1b43']",
"CO Dector": "[amazon_link asins='B000ND74XA,B000MXJ498,B000Q5VMKG' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='11c87bd8-bd59-4059-9a2d-6bd1c400df37']",
"Garage Door Sensor": "[amazon_link asins='B001JDG1KU,B06ZYDH4WK,B075H7Z5L8' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='83e626cf-885d-448d-8c4d-e21220c34b16']",
"Trail Cameras": "[amazon_link asins='B07BHLVXF7,B07D4HPQ4G,B07KT917G4' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='d7059b77-fcfb-42d2-aa98-4c0762834e83']",
"Window Sensor": "[amazon_link asins='B00FGPM1SS,B07FB99J3G,B017LRXADI' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='c3bfad5f-c96f-4ab4-93bb-c9684738ea2a']",
"SmartThings": "[amazon_link asins='B07FJGGWJL,B077JRBSSZ,B010NZV0GE' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='549f3ba7-610c-4491-93b6-62a41a5a4384']",
"Smart Thermostats": "[amazon_link asins='B06W56TBLN,B06W2LQY6L,B01LTHM8LG' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='5bf45bf5-9ee2-4add-b0a7-d2697ef4ad9c']",
"Simplisafe": "[amazon_link asins='B07C38HT49,B07D7Q6CHB,B07CJC5116' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='c1499a0f-4686-476b-9006-491f10bc70aa']",
"Motion Detector": "[amazon_link asins='B07DHXB6XV,B07DNSZPXG,B00HFZUKGM' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='f93e3266-e5db-4644-8c7a-3e20cadbe3bf']",
"Smart Lighting": "[amazon_link asins='B073SSK6P8,B07354SP1C,B079ZLHQM9' template='PAProductGrid' store='homegeek03-20' marketplace='US' link_id='8be17a8d-be00-44fc-a814-f8e0e8510ab5']"
}
niches = ["Amazon Alexa", "Smart Door Locks", "Smoke", "Security Cameras", "Doorbell Cameras", "CO Dector",
"Garage Door Sensor", "Trail Cameras", "Window Sensor", "SmartThings", "Smart Thermostats", "Simplisafe",
"Motion Detector", "Smart Lighting"]
def run(continue_mode=False):
print('1: Issue\n2: No Issue')
print('-' * 15)
print(' ')
with open('./assets/monitization.txt', 'r+') as links:
past_links = []
with open(output_file, 'r', encoding='utf-8-sig') as past_choices:
[past_links.append(x['url']) for x in csv.DictReader(past_choices)]
if len(past_links) == 0:
with open(output_file, 'a+', encoding='utf-8-sig', newline='') as create_choices:
writer = csv.writer(create_choices)
writer.writerow(['url', 'affiliate choice'])
for link in links:
if link.strip() in [x.strip() for x in past_links]:
continue
else:
print('Current: ' + link.strip())
print('test', "\"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe\" \"{link}\"".format(link=link.strip()))
os.popen("\"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe\" \"{link}\"".format(link=link.strip()))
while True:
try:
for count, item in enumerate(niches):
print(f'{count +1}: {item}')
choice = input('What say you? ')
print(' ')
pyperclip.copy(options[niches[int(choice) - 1]])
with open(output_file, 'a+', encoding='utf-8-sig', newline='') as new_choices:
writer = csv.writer(new_choices)
writer.writerow([link.strip(), niches[int(choice) - 1]])
print(' ')
print(f'{niches[int(choice) - 1]} copied to clipboard and saved.')
print(' ')
except KeyError:
print('Invalid Input')
continue
else:
break
if __name__ == "__main__":
run(continue_mode=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment