-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
115 lines (94 loc) · 7.62 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import requests
from pytrends.request import TrendReq
import PySimpleGUI as sg
from string import ascii_lowercase
import re
# PySimpleGUI
sg.theme('Dark Black')
sg.theme_input_text_color('black')
layout = [[sg.Text('\nEnter 2-3 keywords about your article topic:\n', font=25)],
[sg.Input(key='-INPUT2-', background_color='white')], [sg.Button('SUBMIT')], [sg.Text('Results:', font=(100, 40))],
[sg.Text('(Choose 1 keyword phrase from each category)', font=25)], [sg.Button('More LONG-TAIL', key='-MORE2-', visible=False, tooltip='Place these in a <title> tag\nIn the first 100 words\nIn an image alt text\nIn an <h1> tag\nIn an <h2> or <h3> tag\nIn the last 100 words of your page!')],
[sg.Text('Sorry, you used all 25 searches', visible=False, text_color='red', key='-TEXT1-')],
[sg.Multiline('', size=(40, 17), disabled=True, key='-RESULTS-', text_color='orange'), sg.Multiline('', size=(40, 17), disabled=True, key='-RESULTS1-', text_color='orange')]]
window = sg.Window('AutomaticSEO', layout, default_element_size=(65, 1), default_button_element_size=(100, 2),
icon=b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAiTSURBVFhHnVdZc1THFf7uNndWzSINWkcISWAWAQrgShGIbVJ27LgqVXlwUsljnvOeV+x/kpdU5T2Vh5RJUlSBXa7ExAahCC0gltE6+3r3ztd3GCFRCEjOVE/37eV855w+fbqPgjfQ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1Dz+Ws33k9T++TGz2F7gulvcVSzT7KseqluW9szqxFaEHX/GqNWFCDx4dh1euOcRmK1Ran6Wmv8AieAkX6e8z7i/fe16+3uQ9o/R8QK+jtrse8rPFW7mshSg7qL5lE+rJSfY3bQ7257DI+a0qnCsGl8zfHjaAczKBAbKlzDofMyDdpGwsbfWXNJzzR3irVGAbynSOl2yrjJx8HhGGa2dr/yg+43WSu1olbQQDY8RwoHaisNsTiDVOo+UNY94cIKa56iRuifAmzSXRO099m1yzdesv+JLe1tih4FnAj92FIw/U4XSiNojs1o3MeZ6O7p0lVh9Gqn2RWTt93iQjlPzOFe8gHwVeJ/kmNRcCsNSZ/kXAf/YoQAetX+ML4ID63+C0riN4m/bytK1RvwbZkHGUMKaSyT9OYaYOfq5Hj5A3oYkYwnMf7nn29R8kR98loPPciYVz+mAAKexEEnzhhdonxMaPtVF8kokyJ6NYmRvomTaY/xqkvNkkaaV0YYJyT3Ov83y5sSkT79katZlnkKpr3LCBXaFqRmhw9SMzGSyJDGe+1boDj7nSsY2x/dSMw4wNQNTM+XNqVmfrjPo0k1zXMz8AEfJkMmp2JecMvK8lJyyHJKc4n9PTvfT69Jz1mF6zr7/Mz0H/gv9rq5l2k7k+wAAAABJRU5ErkJggg==',
size=(700, 600), element_justification='c')
current_letter = 'a'
while True:
event, values = window.read(timeout=100)
if event == sg.WIN_CLOSED:
break
if event == 'SUBMIT':
window['-MORE2-'].update(disabled=False)
window['-TEXT1-'].update(visible=False)
additional_queries = {
"a": "",
"b": "",
"c": "",
"d": "",
"e": "",
"f": "",
"g": "",
"h": "",
"i": "",
"j": "",
"k": "",
"l": "",
"m": "",
"n": "",
"o": "",
"p": "",
"q": "",
"r": "",
"s": "",
"t": "",
"u": "",
"v": "",
"w": "",
"x": "",
"y": "",
"z": "",
}
current_letter = 'a'
window['-MORE2-'].update(visible=True)
key_query = window['-INPUT2-'].get()
# pytrends
pytrends = TrendReq(hl='en-US', tz=360)
kw_list = [key_query]
pytrends.build_payload(kw_list)
try:
related_queries = pytrends.related_queries()
except:
related_queries = ['nothing']
top = list(related_queries.values())[0]['top']
window['-RESULTS1-'].update('LSI KEYWORDS:\n\n')
window['-RESULTS1-'].update(top, append=True)
window['-RESULTS1-'].update('\n\nPLACE THESE:\n\nIn several places anywhere along your webpage', append=True)
key_query = key_query.strip().replace(' ', '%20')
# cache Long-Tail keywords
for i in ascii_lowercase:
#TODO - make these async
response2 = requests.get(
f"https://suggestqueries.google.com/complete/search?jsonp=jQuery22402686540572534406_040466655432741216&q={key_query}%20{i}&client=chrome&_=0005610362715791517")
response_text2 = response2.text
# convert response string to list
res_arr2 = re.sub('[\"\[\]]', "", response_text2).split(',')
res_arr2 = res_arr2[1:res_arr2.index('') if '' in res_arr2 else 16]
additional_queries[i] = res_arr2
# get initial query
response = requests.get(
f"https://suggestqueries.google.com/complete/search?jsonp=jQuery22402686540572534406_040466655432741216&q={key_query}&client=chrome&_=0005610362715791517")
response_text = response.text
# convert response string to list
res_arr = re.sub('[\"\[\]]', "", response_text).split(',')
res_arr = res_arr[1:res_arr.index('') if '' in res_arr else 16]
window['-RESULTS-'].update('LONG-TAIL KEYWORDS: \n\n' + ', '.join(res_arr) + '\n\nPLACE THESE:\n\nIn a <title> tag\nIn the first 100 words\nIn an image alt text\nIn an <h1> tag\nIn an <h2> or <h3> tag\nIn the last 100 words of your page!')
if event == '-MORE2-':
if current_letter == '{':
window['-TEXT1-'].update(visible=True)
window['-MORE2-'].update(disabled=True)
else:
window['-RESULTS-'].update('LONG-TAIL KEYWORDS: \n\n' + ', '.join(additional_queries.get(current_letter)) + '\n\nPLACE THESE:\n\nIn a <title> tag\nIn the first 100 words\nIn an image alt text\nIn an <h1> tag\nIn an <h2> or <h3> tag\nIn the last 100 words of your page!')
current_letter = chr(ord(current_letter) + 1)
window.close()