-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.py
73 lines (61 loc) · 2.83 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
'''
Nebula Keyword Researcher: is designed to scrape keywords from
major search engines like Google, Bing and Yahoo.
Copyright (C) 2021. Eneiro A. Matos B.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
from search_engines import SearchEngineSuggestions as SES
from file_writter import FileWriter as FW
from string import ascii_lowercase
import config
import sys
try:
seed_kws = open(config.input_file, encoding='utf-8')
except FileNotFoundError:
open(config.input_file, mode='w', encoding='utf-8')
print(f'The file {config.input_file} has been created.\n'
f'Proceed as follow:\n'
f'\t1. Put your initial keyword there, one per line.\n'
f'\t2. Pun this file again to scrape new keywords.\n')
input('Press any key to exit')
sys.exit()
else:
kw_getters = {'Google': SES.get_google,
'Bing': SES.get_bing,
'Yahoo': SES.get_yahoo,
#'Yandex US': SES.get_yandex_us, RANDOM JSON FORMAT SOMETIMES
'Ask': SES.get_ask,
'DuckDuckGo': SES.get_duckduckgo,
'Ecosia': SES.get_ecosia,
'Brave': SES.get_brave
}
input_kws = [kw.strip('\n').strip() for kw in seed_kws.readlines() if kw not in ('', ' ', '\n', None)]
if len(input_kws) == 0:
print(f'Please insert at least one keyword in {config.input_file} to start, and try again.')
input('Press any key to exit')
sys.exit()
print(f'{len(input_kws)} keywords will be scanned against {len(kw_getters)} search engines.\n'
f'This process may take some time, please be patient.\n')
input('Press any key to continue\n')
for kw in input_kws:
kws = tuple()
for letter in ascii_lowercase:
new_kw = f'{kw} {letter}'
for se, getter in kw_getters.items():
print(f'Exploring for {new_kw} in {se}')
kw_ses = SES.kw_results(getter, new_kw)
kws += kw_ses
print(f'{len(kw_ses)} keywords found in this step.\n')
FW.write_txt(kws)
with open(config.output_file, encoding='utf-8') as out_f:
print(f'File {config.output_file} has been created, '
f'{len(out_f.readlines())} unique keywords found.')