-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSC_VPS.py
108 lines (80 loc) · 3.58 KB
/
RSC_VPS.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
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("/home/RSC.txt", 'a') as f:
f.write(content)
launch_kwargs = {
"headless": True,
"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": "/home/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*800})
time.sleep(2)
account_sid = '**************************'
auth_token = '**************************'
myNumber = '+**************************'
twilioNumber = '+**************************'
APP_ID = '**************************'
API_KEY = '**************************'
SECRET_KEY = '**************************'
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,
})
""")
await page.goto('https://mc.manuscriptcentral.com/gc', {'timeout': 1000*800})
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')
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()
saveFile(title_str + ' ' + currentTime + '\n')
await textmyself(title_str)
await asyncio.sleep(1)
await browser.close()
asyncio.get_event_loop().run_until_complete(main())