-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconmain.py
87 lines (77 loc) · 2.63 KB
/
conmain.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
import constants as const
from modules import *
try:
import requests
from bs4 import BeautifulSoup
except ImportError:
import_y_n = input(const.PLEASE_INSTALL_PIP_TEXT)
if import_y_n.lower() == "y":
import os
os.system("pip install bs4")
os.system("pip install requests")
else:
exit()
class main(object):
def __init__(self: object) -> None:
"""
This function is used to initialize the class.
"""
ALL_CONSTANTS_IN_LIST = self.get_all_constants()
self.SEARCH_STRING = ALL_CONSTANTS_IN_LIST[0]
self.AMOUNT_OF_WEBSITES_TO_SEND_FORMS_TO = ALL_CONSTANTS_IN_LIST[1]
self.FORM_NAME = ALL_CONSTANTS_IN_LIST[2]
self.FORM_EMAIL = ALL_CONSTANTS_IN_LIST[3]
self.FORM_PHONE = ALL_CONSTANTS_IN_LIST[4]
self.FORM_COMMENT = ALL_CONSTANTS_IN_LIST[5]
self.ADD_SPECIFIC_WEBSITES = ALL_CONSTANTS_IN_LIST[6]
self.SearchStartNum = 0
self.websites = []
self.SuccessfullForms = 0
self.FailedForms = 0
def main(self: object) -> None:
"""
This is a main method in the main class.
Args:
self: The object.
Returns:
None.
"""
if self.ADD_SPECIFIC_WEBSITES:
self.collect_specific_websites()
temp = Collect_websites(
SEARCH_STRING=self.SEARCH_STRING,
SearchStartNum=self.SearchStartNum,
AMOUNT_OF_WEBSITES_TO_SEND_FORMS_TO=self.AMOUNT_OF_WEBSITES_TO_SEND_FORMS_TO,
websites=self.websites,
).collect_and_append_websites()
websites = temp[0]
self.url = temp[1]
Submit_forms(
formname=self.FORM_NAME,
formemail=self.FORM_EMAIL,
formphone=self.FORM_PHONE,
formcomment=self.FORM_COMMENT,
websites=websites,
url=self.url,
console=None).main()
def collect_specific_websites(self) -> None:
"""
This function collects the websites from the file and appends them to the websites list.
:param self: The object.
:param websites: The list of websites.
:return: None
"""
try:
with open(const.TXT_FILE_TEXT, "ר") as file:
for website in file:
self.websites.append(website.strip())
except:
print(const.COULD_NOT_ADD_THE_WEBSITE_TEXT)
exit()
def get_all_constants(self) -> list:
alldata = User_settings_util().get_all_data()
print(alldata)
return alldata
if __name__ == "__main__":
main = main()
main.main()