-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver1.py
128 lines (118 loc) · 5.47 KB
/
server1.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
116
117
118
119
120
121
122
123
124
125
126
127
128
# import pandas as pd
# import urllib, requests
# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.chrome.options import Options
# from selenium.webdriver.chrome.service import Service
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.common.keys import Keys
# from selenium.webdriver.support import expected_conditions as EC
# import time
# import random
# from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM
# import sys,re
# PORT_NUMBER = 5000
# SIZE = 1024
# hostName = gethostbyname( '0.0.0.0' )
# mySocket = socket( AF_INET, SOCK_DGRAM )
# mySocket.bind( (hostName, PORT_NUMBER) )
# print ("Test server listening on port {0}\n".format(PORT_NUMBER))
# s = "Hello Client"
def convert(copy):
disp_ans =''
for i in copy:
if i == ' ':
disp_ans+=i+' '
disp_ans+=i+' '
return disp_ans
# data,addr = mySocket.recvfrom(SIZE)
# mySocket.sendto('connected'.encode(),(addr))
# print(data.decode())
# print(addr)
# # mySocket.sendto(s.encode(),addr)
# try:
# dic = {'[email protected]':'hello12345678','[email protected]':'JPYVDTLX','[email protected]':'CJNYJAMN','[email protected]':'JFLBAUEC'}
# ch = random.choice(list(dic))
# print(ch)
# df = pd.read_csv(r'Skribbl-words.csv')
# df_new = (df['word'])
# PATH = Service(r'C:\Users\joelr\Downloads\installers\chromedriver_win32\chromedriver.exe')
# options = Options()
# options.binary_location = r'C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe'
# options.accept_insecure_certs = True
# # options.headless = True
# driver = webdriver.Chrome( service = PATH,options = options)
# driver.get('https://freeimagegenerator.com/')
# print('opened website --> waiting for sign in')
# sign = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/nav/div[3]/div/div[2]/ul/li/a"))).click()
# art = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[2]/div/div/a[1]"))).click()
# user = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[2]/div/form/div/div[1]/input"))).send_keys(ch)
# pswrd = driver.find_element(By.XPATH,"/html/body/div[2]/div/form/div/div[2]/input")
# pswrd.send_keys(dic[ch])
# login =driver.find_element(By.XPATH,"/html/body/div[2]/div/form/div/div[3]/a")
# login.click()
# print('Sign-in done')
# head = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,"/html/body/header/div/div/div[1]/a[1]"))).click()
# prompt= WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[3]/div/div[2]/div[2]/div[1]/div[1]/input")))
# l = list(df_new.sample(n=2))
# s=" ".join(l)
# s= s.lower()
# print(s)
# copy = ''
# prompt.send_keys(s)
# prompt.send_keys(Keys.ENTER)
# print('Enterred prompt')
# img = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[3]/div/div[2]/div[6]/button[1]"))).click()
# print('got results --> waiting for image')
# element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[2]/div/div[2]/div[6]/a/img")))
# src = driver.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div[6]/a/img").get_attribute("src")
# print(src+ "\n\n")
# mySocket.sendto(src.encode('utf-8'),(addr))
# print('sent img')
# vowel = ['a','e','i','o','u']
# s = s.lower()
# for i in s:
# if i != ' ':
# if i not in vowel:
# copy+='_'
# else:
# copy+=i
# else:
# copy+=i
# print(convert(copy))
# mySocket.sendto(convert(copy).encode('utf-8'),(addr))
# print('Sent Prompt String')
# # with open('filename.png', 'wb') as file:
# # file.write(driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/div[4]/a/img').screenshot_as_png)
# head =WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,"/html/body/header/div/div/div[1]/a[1]"))).click()
# # prompt = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[3]/div/div[2]/div[2]/div[1]/div[1]/input")))
# while(1):
# check,addr = mySocket.recvfrom(SIZE)
# check = check.decode().lower()
# if check == '__':
# mySocket.sendto(s.encode('utf-8'),(addr))
# break
# if check ==s:
# msg = 'you goddit!!'
# mySocket.sendto(msg.encode('utf-8'),(addr))
# mySocket.sendto(s.encode('utf-8'),(addr))
# break
# else:
# if check in s and len(check)>0:
# print(copy)
# for m in re.finditer(check, s):
# print(check, 'matched from position', m.start(), 'to', m.end())
# copy = copy.replace(copy[m.start():m.end()],check)
# print(copy)
# if copy == s:
# msg = 'you goddit!!'
# mySocket.sendto(msg.encode('utf-8'),(addr))
# mySocket.sendto(s.encode('utf-8'),(addr))
# break
# mySocket.sendto(check.encode('utf-8'),(addr))
# mySocket.sendto(convert(copy).encode('utf-8'),(addr))
# # mySocket.sendto(bit.encode('utf-8'),(addr))
# except Exception as e:
# print(e)
# driver.quit()
# quit()