-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSC.py
121 lines (90 loc) · 3.76 KB
/
RSC.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
import time
import random
import asyncio
from pyppeteer import launch
from twilio.rest import Client
def input_time_random():
return random.randint(100, 151)
def saveFile(content):
with open(r"C:\Users\*****\Desktop\RSC.txt", 'a') as f:
f.write(content)
def screen_size():
"""使用tkinter获取屏幕大小"""
import tkinter
tk = tkinter.Tk()
width = tk.winfo_screenwidth()
height = tk.winfo_screenheight()
tk.quit()
return width, height
launch_kwargs = {
"headless": False,
"args": [
"--start-maximized",
"--no-sandbox",
"--disable-infobars",
"--log-level=3",
"--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
"--accept-language=zh-CN,zh;q=0.9,und;q=0.8,en;q=0.7"
],
"userDataDir": "F:\\manutus\\rscUserDataDir"
}
async def stimulateClick(page, selector):
box = await selector.boundingBox()
x = box['x'] + (box['width'] / 2)
y = box['y'] + (box['height'] / 2)
await page.mouse.click(x, y)
await page.waitFor(20)
await page.waitForNavigation({'timeout': 1000*240})
time.sleep(2)
account_sid = '*****************'
auth_token = '*****************'
myNumber = '*****************'
twilioNumber = '*****************'
async def textmyself(message):
client = Client(account_sid, auth_token)
message = client.messages.create(to=myNumber, from_=twilioNumber, body=message)
async def main():
browser = await launch(launch_kwargs)
page = await browser.newPage()
await page.evaluateOnNewDocument("""
var _navigator = {};
for (name in window.navigator) {
if (name != "webdriver") {
_navigator[name] = window.navigator[name]
}
}
Object.defineProperty(window, 'navigator', {
get: ()=> _navigator,
})
""")
width, height = screen_size()
await page.setViewport({"width": width, "height": height})
await page.goto('************************')
await page.waitFor('#logInButton')
await page.type('#USERID', '*************', {'delay': input_time_random() - 50})
await page.type('#PASSWORD', '**************', {'delay': input_time_random()})
clickButton = await page.querySelector("#logInButton")
await stimulateClick(page, clickButton)
auther_ui = await page.querySelector('#header > div > div.nav-collapse.toplvlnav > div > ul > li:nth-child(2) > a')
await stimulateClick(page, auther_ui)
await page.waitForSelector('#default_form > div.container > div')
currentTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
try:
status = await page.querySelector('#queue_0 > td:nth-child(1)')
true_status = await status.querySelector(
'#queue_0 > td:nth-child(1) > table > tbody > tr > td:nth-child(2) > span')
title_str = await (await true_status.getProperty('textContent')).jsonValue()
saveFile(title_str + ' ' + currentTime + '\n')
print(title_str)
print(currentTime)
except AttributeError:
status = await page.querySelector('#queue_0 > td:nth-child(2)')
true_status = await status.querySelector(
'#queue_0 > td:nth-child(2) > table > tbody > tr > td:nth-child(2) > span')
title_str = await (await true_status.getProperty('textContent')).jsonValue()
print(title_str)
print(currentTime)
await textmyself(title_str)
await asyncio.sleep(1)
await browser.close()
asyncio.get_event_loop().run_until_complete(main())