PySPlus 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pysplus-0.1/PKG-INFO +36 -0
- pysplus-0.1/PySPlus.egg-info/PKG-INFO +36 -0
- pysplus-0.1/PySPlus.egg-info/SOURCES.txt +11 -0
- pysplus-0.1/PySPlus.egg-info/dependency_links.txt +1 -0
- pysplus-0.1/PySPlus.egg-info/requires.txt +2 -0
- pysplus-0.1/PySPlus.egg-info/top_level.txt +1 -0
- pysplus-0.1/README.md +14 -0
- pysplus-0.1/pysplus/Client.py +136 -0
- pysplus-0.1/pysplus/__init__.py +5 -0
- pysplus-0.1/pysplus/colors.py +20 -0
- pysplus-0.1/pysplus/test.py +8 -0
- pysplus-0.1/setup.cfg +4 -0
- pysplus-0.1/setup.py +16 -0
pysplus-0.1/PKG-INFO
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: PySPlus
|
3
|
+
Version: 0.1
|
4
|
+
Summary: the library SPlus platform for bots.
|
5
|
+
Home-page: https://github.com/OandONE/PySPlus
|
6
|
+
Author: seyyed mohamad hosein moosavi raja(01)
|
7
|
+
Author-email: mohamadhosein159159@gmail.com
|
8
|
+
License: MIT
|
9
|
+
Requires-Python: >=3.8
|
10
|
+
Description-Content-Type: text/markdown
|
11
|
+
Requires-Dist: selenium==4.29.0
|
12
|
+
Requires-Dist: webdriver_manager==4.0.2
|
13
|
+
Dynamic: author
|
14
|
+
Dynamic: author-email
|
15
|
+
Dynamic: description
|
16
|
+
Dynamic: description-content-type
|
17
|
+
Dynamic: home-page
|
18
|
+
Dynamic: license
|
19
|
+
Dynamic: requires-dist
|
20
|
+
Dynamic: requires-python
|
21
|
+
Dynamic: summary
|
22
|
+
|
23
|
+
# fast rub
|
24
|
+
|
25
|
+
This Python library is for SPlus platform bots and is currently being updated.
|
26
|
+
|
27
|
+
## fast rub
|
28
|
+
|
29
|
+
- 1 fast
|
30
|
+
- 2 simple syntax
|
31
|
+
- 3 Small size of the library
|
32
|
+
|
33
|
+
## install :
|
34
|
+
|
35
|
+
```bash
|
36
|
+
pip install https://ParsSource.ir/PySPlus/PySPlus-0.1.tar.gz
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: PySPlus
|
3
|
+
Version: 0.1
|
4
|
+
Summary: the library SPlus platform for bots.
|
5
|
+
Home-page: https://github.com/OandONE/PySPlus
|
6
|
+
Author: seyyed mohamad hosein moosavi raja(01)
|
7
|
+
Author-email: mohamadhosein159159@gmail.com
|
8
|
+
License: MIT
|
9
|
+
Requires-Python: >=3.8
|
10
|
+
Description-Content-Type: text/markdown
|
11
|
+
Requires-Dist: selenium==4.29.0
|
12
|
+
Requires-Dist: webdriver_manager==4.0.2
|
13
|
+
Dynamic: author
|
14
|
+
Dynamic: author-email
|
15
|
+
Dynamic: description
|
16
|
+
Dynamic: description-content-type
|
17
|
+
Dynamic: home-page
|
18
|
+
Dynamic: license
|
19
|
+
Dynamic: requires-dist
|
20
|
+
Dynamic: requires-python
|
21
|
+
Dynamic: summary
|
22
|
+
|
23
|
+
# fast rub
|
24
|
+
|
25
|
+
This Python library is for SPlus platform bots and is currently being updated.
|
26
|
+
|
27
|
+
## fast rub
|
28
|
+
|
29
|
+
- 1 fast
|
30
|
+
- 2 simple syntax
|
31
|
+
- 3 Small size of the library
|
32
|
+
|
33
|
+
## install :
|
34
|
+
|
35
|
+
```bash
|
36
|
+
pip install https://ParsSource.ir/PySPlus/PySPlus-0.1.tar.gz
|
@@ -0,0 +1,11 @@
|
|
1
|
+
README.md
|
2
|
+
setup.py
|
3
|
+
PySPlus.egg-info/PKG-INFO
|
4
|
+
PySPlus.egg-info/SOURCES.txt
|
5
|
+
PySPlus.egg-info/dependency_links.txt
|
6
|
+
PySPlus.egg-info/requires.txt
|
7
|
+
PySPlus.egg-info/top_level.txt
|
8
|
+
pysplus/Client.py
|
9
|
+
pysplus/__init__.py
|
10
|
+
pysplus/colors.py
|
11
|
+
pysplus/test.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
pysplus
|
pysplus-0.1/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# fast rub
|
2
|
+
|
3
|
+
This Python library is for SPlus platform bots and is currently being updated.
|
4
|
+
|
5
|
+
## fast rub
|
6
|
+
|
7
|
+
- 1 fast
|
8
|
+
- 2 simple syntax
|
9
|
+
- 3 Small size of the library
|
10
|
+
|
11
|
+
## install :
|
12
|
+
|
13
|
+
```bash
|
14
|
+
pip install https://ParsSource.ir/PySPlus/PySPlus-0.1.tar.gz
|
@@ -0,0 +1,136 @@
|
|
1
|
+
from selenium import webdriver
|
2
|
+
from selenium.webdriver.common.by import By
|
3
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
4
|
+
from selenium.webdriver.support import expected_conditions as EC
|
5
|
+
from selenium.webdriver.chrome.service import Service
|
6
|
+
from selenium.webdriver.chrome.options import Options
|
7
|
+
from webdriver_manager.chrome import ChromeDriverManager
|
8
|
+
from .colors import *
|
9
|
+
from typing import Optional
|
10
|
+
import time,os,json,asyncio,logging,pickle
|
11
|
+
|
12
|
+
logging.getLogger('selenium').setLevel(logging.WARNING)
|
13
|
+
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
14
|
+
logging.getLogger('WDM').setLevel(logging.WARNING)
|
15
|
+
|
16
|
+
os.environ['WDM_LOG_LEVEL'] = '0'
|
17
|
+
os.environ['WDM_PRINT_FIRST_LINE'] = 'False'
|
18
|
+
|
19
|
+
class Client:
|
20
|
+
def __init__(self,
|
21
|
+
name_session: str,
|
22
|
+
display_welcome=True,
|
23
|
+
user_agent: Optional[str] = None,
|
24
|
+
time_out: Optional[int] = 60,
|
25
|
+
number_phone: Optional[str] = None
|
26
|
+
):
|
27
|
+
self.number_phone = number_phone
|
28
|
+
name = name_session + ".pysplus"
|
29
|
+
self.name_cookies = name_session + "_cookies.pkl"
|
30
|
+
if os.path.isfile(name):
|
31
|
+
with open(name, "r", encoding="utf-8") as file:
|
32
|
+
text_json_py_slpus_session = json.load(file)
|
33
|
+
self.number_phone = text_json_py_slpus_session["number_phone"]
|
34
|
+
self.time_out = text_json_py_slpus_session["time_out"]
|
35
|
+
self.user_agent = text_json_py_slpus_session["user_agent"]
|
36
|
+
self.display_welcome = text_json_py_slpus_session["display_welcome"]
|
37
|
+
asyncio.run(self.login())
|
38
|
+
else:
|
39
|
+
if not number_phone:
|
40
|
+
number_phone = input("Enter your phone number : ")
|
41
|
+
if number_phone.startswith("0"):
|
42
|
+
number_phone = number_phone[1:]
|
43
|
+
while number_phone in ["", " ", None] or self.check_phone_number(number_phone)==False:
|
44
|
+
cprint("Enter the phone valid !",Colors.RED)
|
45
|
+
number_phone = input("Enter your phone number : ")
|
46
|
+
if number_phone.startswith("0"):
|
47
|
+
number_phone = number_phone[1:]
|
48
|
+
is_login = asyncio.run(self.login())
|
49
|
+
if not is_login:
|
50
|
+
print("Error Login !")
|
51
|
+
exit()
|
52
|
+
text_json_py_slpus_session = {
|
53
|
+
"name_session": name_session,
|
54
|
+
"number_phone":number_phone,
|
55
|
+
"user_agent": user_agent,
|
56
|
+
"time_out": time_out,
|
57
|
+
"display_welcome": display_welcome,
|
58
|
+
}
|
59
|
+
with open(name, "w", encoding="utf-8") as file:
|
60
|
+
json.dump(
|
61
|
+
text_json_py_slpus_session, file, ensure_ascii=False, indent=4
|
62
|
+
)
|
63
|
+
self.time_out = time_out
|
64
|
+
self.user_agent = user_agent
|
65
|
+
self.number_phone = number_phone
|
66
|
+
if display_welcome:
|
67
|
+
k = ""
|
68
|
+
for text in "Welcome to PySPlus":
|
69
|
+
k += text
|
70
|
+
print(f"{Colors.GREEN}{k}{Colors.RESET}", end="\r")
|
71
|
+
time.sleep(0.07)
|
72
|
+
cprint("",Colors.WHITE)
|
73
|
+
def check_phone_number(self,number:str) -> bool:
|
74
|
+
if len(number)!=10:
|
75
|
+
return False
|
76
|
+
if not number.startswith("9"):
|
77
|
+
return False
|
78
|
+
return True
|
79
|
+
async def login(self):
|
80
|
+
chrome_options = Options()
|
81
|
+
chrome_options.add_argument("--start-maximized")
|
82
|
+
chrome_options.add_argument("--disable-notifications")
|
83
|
+
chrome_options.add_argument("--lang=fa")
|
84
|
+
chrome_options.add_experimental_option("detach", True)
|
85
|
+
service = Service(ChromeDriverManager().install())
|
86
|
+
driver = webdriver.Chrome(service=service, options=chrome_options)
|
87
|
+
wait = WebDriverWait(driver, 15)
|
88
|
+
try:
|
89
|
+
driver.get("https://web.splus.ir")
|
90
|
+
time.sleep(1)
|
91
|
+
is_open_cookies = False
|
92
|
+
if os.path.exists(self.name_cookies):
|
93
|
+
with open(self.name_cookies, 'rb') as file:
|
94
|
+
cookies = pickle.load(file)
|
95
|
+
for cookie in cookies:
|
96
|
+
driver.add_cookie(cookie)
|
97
|
+
is_open_cookies = True
|
98
|
+
if is_open_cookies:
|
99
|
+
driver.refresh()
|
100
|
+
try:
|
101
|
+
understand_button = WebDriverWait(driver, 3).until(
|
102
|
+
EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'متوجه شدم')]"))
|
103
|
+
)
|
104
|
+
understand_button.click()
|
105
|
+
time.sleep(1)
|
106
|
+
except:
|
107
|
+
pass
|
108
|
+
phone_input = wait.until(
|
109
|
+
EC.presence_of_element_located((By.CSS_SELECTOR, "input#sign-in-phone-number"))
|
110
|
+
)
|
111
|
+
phone_input.clear()
|
112
|
+
phone_number = f"98 98{self.number_phone}"
|
113
|
+
phone_input.send_keys(phone_number)
|
114
|
+
next_button = wait.until(
|
115
|
+
EC.element_to_be_clickable((By.XPATH, "//button[contains(@class, 'Button') and contains(text(), 'بعدی')]"))
|
116
|
+
)
|
117
|
+
next_button.click()
|
118
|
+
time.sleep(5)
|
119
|
+
verification_code = input("Enter the Code » ")
|
120
|
+
code_input = wait.until(
|
121
|
+
EC.presence_of_element_located((By.CSS_SELECTOR, "input#sign-in-code"))
|
122
|
+
)
|
123
|
+
code_input.clear()
|
124
|
+
code_input.send_keys(verification_code)
|
125
|
+
verify_button = wait.until(
|
126
|
+
EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'تأیید') or contains(text(), 'Verify')]"))
|
127
|
+
)
|
128
|
+
verify_button.click()
|
129
|
+
time.sleep(5)
|
130
|
+
with open(self.name_cookies, 'wb') as file:
|
131
|
+
pickle.dump(driver.get_cookies(), file)
|
132
|
+
return True
|
133
|
+
except Exception as e:
|
134
|
+
driver.save_screenshot("error_screenshot.png")
|
135
|
+
print(e)
|
136
|
+
return False
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Colors:
|
2
|
+
BLACK = '\033[30m'
|
3
|
+
RED = '\033[31m'
|
4
|
+
GREEN = '\033[32m'
|
5
|
+
YELLOW = '\033[33m'
|
6
|
+
BLUE = '\033[34m'
|
7
|
+
MAGENTA = '\033[35m'
|
8
|
+
CYAN = '\033[36m'
|
9
|
+
WHITE = '\033[37m'
|
10
|
+
LIGHT_RED = '\033[91m'
|
11
|
+
LIGHT_GREEN = '\033[92m'
|
12
|
+
LIGHT_YELLOW = '\033[93m'
|
13
|
+
LIGHT_BLUE = '\033[94m'
|
14
|
+
LIGHT_MAGENTA = '\033[95m'
|
15
|
+
LIGHT_CYAN = '\033[96m'
|
16
|
+
BOLD = '\033[1m'
|
17
|
+
UNDERLINE = '\033[4m'
|
18
|
+
RESET = '\033[0m'
|
19
|
+
def cprint(text, color=Colors.WHITE, end='\n'):
|
20
|
+
print(f"{color}{text}{Colors.RESET}", end=end)
|
pysplus-0.1/setup.cfg
ADDED
pysplus-0.1/setup.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
from setuptools import setup, find_packages
|
2
|
+
|
3
|
+
setup(
|
4
|
+
name="PySPlus",
|
5
|
+
version="0.1",
|
6
|
+
author="seyyed mohamad hosein moosavi raja(01)",
|
7
|
+
author_email="mohamadhosein159159@gmail.com",
|
8
|
+
description="the library SPlus platform for bots.",
|
9
|
+
long_description=open("README.md").read(),
|
10
|
+
long_description_content_type="text/markdown",
|
11
|
+
url="https://github.com/OandONE/PySPlus",
|
12
|
+
packages=find_packages(),
|
13
|
+
python_requires='>=3.8',
|
14
|
+
install_requires=["selenium==4.29.0","webdriver_manager==4.0.2"],
|
15
|
+
license="MIT"
|
16
|
+
)
|