-
Notifications
You must be signed in to change notification settings - Fork 42
/
dlt.js
executable file
·243 lines (208 loc) · 7.74 KB
/
dlt.js
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env node
// 模拟方式接单、上传、查看详情(账密),已弃用
const puppeteer = require('puppeteer-core')
const fire = require('js-fire')
const order = async (search = '') => {
const browser = await puppeteer.connect({
browserURL: 'http://localhost:9223',
})
const iPhone = puppeteer.devices['iPhone 6']
const page = await browser.newPage()
await page.emulate(iPhone)
await page.goto('https://m.dailiantong.com/#/pages/notice/notice')
await page.waitForSelector('.nav-left-text')
await page.click('.nav-left-text')
await page.waitForSelector('.uni-indexed-list__item')
await page.click('.uni-indexed-list__item')
await page.waitForSelector('.flex-item')
await page.click('.flex-item')
await page.waitForSelector('[data-text="全部"]')
await page.click('[data-text="全部"]')
await page.waitForSelector('.nav-right')
await page.click('.nav-right')
await page.waitForSelector('.uni-searchbar__box')
await page.click('.uni-searchbar__box')
await page.keyboard.type(search)
await page.waitForSelector('[value="' + search + '"]')
// await page.waitForSelector('.uni-searchbar__cancel')
// await page.click('.uni-searchbar__cancel')
await page.keyboard.press('Enter')
await page.waitForSelector('.uni-list')
await page.waitForSelector('.upwarp-nodata')
const size = await page.$eval('.uni-list', (x) => x.childElementCount)
console.log(size)
if (size !== 1) {
return browser.disconnect()
}
await page.click('.uni-list')
await page.waitForSelector('.title')
const title = await page.$eval('.title', (x) => x.textContent)
const price = await page.$eval('.money', (x) => x.textContent)
console.log(title)
console.log(price)
await page.waitForSelector('.uni-tab__cart-button-right')
await page.click('.uni-tab__cart-button-right')
await page.waitForSelector('.keyboar:nth-child(5)')
await new Promise((r) => setTimeout(r, 500))
await page.click('.keyboar:nth-child(1)')
await page.click('.keyboar:nth-child(1)')
await page.click('.keyboar:nth-child(1)')
await page.click('.keyboar:nth-child(1)')
await page.click('.keyboar:nth-child(1)')
// console.log(price)
// await page.waitForSelector('input')
// await page.screenshot({ path: 'example.png' })
// await new Promise((r) => setTimeout(r, 20000))
// await browser.close()
browser.disconnect()
}
const detail = async (search = '') => {
const browser = await puppeteer.connect({
browserURL: 'http://localhost:9223',
})
const iPhone = puppeteer.devices['iPhone 6']
const page = await browser.newPage()
await page.emulate(iPhone)
await page.goto(
'https://m.dailiantong.com/#/pages/order/order?detailData=%257B%2522publish%2522%253A0%257D'
)
await page.waitForSelector('.uni-nav-bar-right')
await page.click('.uni-nav-bar-right')
// await page.waitForSelector('.uni-searchbar__box')
await new Promise((r) => setTimeout(r, 1000))
// await page.click('.uni-searchbar__box')
await page.keyboard.type(search)
await new Promise((r) => setTimeout(r, 1000))
// await page.waitForSelector('[value="' + search + '"]')
// await page.waitForSelector('.uni-searchbar__cancel')
// await page.click('.uni-searchbar__cancel')
// await page.waitForSelector('.uni-searchbar__box')
// await page.click('.uni-searchbar__box')
await page.keyboard.press('Enter')
// await new Promise((r) => setTimeout(r, 1000))
// await page.waitForSelector('.uni-list-cell')
// await page.click('.uni-list-cell')
await page.waitForFunction(
() => document.querySelectorAll('.uni-list .uni-list-cell').length == 1
)
// await page.waitForSelector('.uni-list-cell')
//
await new Promise((r) => setTimeout(r, 500))
await page.click('.uni-list-cell')
// 校验
await page.waitForSelector('.orderInformationList span')
const info2 = await page.$$eval('.orderInformationList span', (x) =>
x.map((x) => x.textContent).join(' ')
)
if (!info2.includes(search)) {
console.log('校验失败', info2, search)
return
}
// exit()
// const size = await page.$eval('.uni-list', (x) => x.childElementCount)
// console.log(size)
// if (size !== 1) {
// return browser.disconnect()
// }
await page.waitForSelector('.subtitle')
await page.click('.subtitle')
await page.waitForSelector('.uni-tip-button')
await page.click('.uni-tip-button')
// uni-nav-bar-right
await page.waitForFunction(
() =>
!document.querySelector('.informationList span').textContent.endsWith('*')
)
const info = await page.$$eval('.informationList span', (x) =>
x.map((x) => x.textContent).join(' ')
)
// const info2 = await page.$$eval('.orderInformationList span', (x) =>
// x.map((x) => x.textContent).join(' ')
// )
// const username = await page.$eval(
// '.informationList span',
// (x) => x.textContent
// )
// const password = await page.$eval(
// '.informationList:nth-child(2) span',
// (x) => x.textContent
// )
// const phone = await page.$eval(
// '.informationList:nth-child(3) span',
// (x) => x.textContent
// )
// const name = await page.$eval(
// '.informationList:nth-child(4) span',
// (x) => x.textContent
// )
// const name = await page.$eval(
// '.informationList:nth-child(4) span',
// (x) => x.textContent
// )
const title = await page.$eval('.title', (x) => x.textContent)
const area = await page.$eval('.area', (x) => x.textContent)
console.log(info, info2, title, area.replace('明日方舟', ''))
browser.disconnect()
}
const upload = async (search = '', path = '') => {
const browser = await puppeteer.connect({
browserURL: 'http://localhost:9223',
})
const iPhone = puppeteer.devices['iPhone 6']
const page = await browser.newPage()
await page.emulate(iPhone)
await page.goto(
'https://m.dailiantong.com/#/pages/order/order?detailData=%257B%2522publish%2522%253A0%257D'
)
await page.waitForSelector('.uni-nav-bar-right')
await page.click('.uni-nav-bar-right')
await page.waitForSelector('.uni-searchbar__box')
await page.click('.uni-searchbar__box')
await new Promise((r) => setTimeout(r, 1000))
await page.keyboard.type(search)
// await page.waitForSelector('[value="' + search + '"]')
// await page.waitForSelector('.uni-searchbar__cancel')
// await page.click('.uni-searchbar__cancel')
// await page.click('.uni-searchbar__box')
await new Promise((r) => setTimeout(r, 1000))
await page.keyboard.press('Enter')
// await new Promise((r) => setTimeout(r, 500))
//
await page.waitForFunction(
() => document.querySelectorAll('.uni-list .uni-list-cell').length == 1
)
await new Promise((r) => setTimeout(r, 500))
await page.waitForSelector('.uni-list-cell')
await page.click('.uni-list-cell')
// 校验
await page.waitForSelector('.orderInformationList span')
const info2 = await page.$$eval('.orderInformationList span', (x) =>
x.map((x) => x.textContent).join(' ')
)
if (!info2.includes(search)) {
console.log('校验失败', info2, search)
return
}
await page.waitForSelector('.uni-tab__right')
await page.click('.uni-tab__right')
await page.waitForSelector('.sunui-uploader-inputbox')
await page.click('.sunui-uploader-inputbox')
// const fileChooser = await page.waitForFileChooser()
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('.sunui-uploader-inputbox'),
// page.click('#upload-file-button'), // some button that triggers file selection
])
await fileChooser.accept([path])
// TODO
console.log(155)
// await page.click('.submitBtn')
await new Promise((r) => setTimeout(r, 1000))
// TODO,支持两个图
await page.waitForSelector('.submitBtn')
console.log(156)
// await page.click('.submitBtn')
browser.disconnect()
}
// .uni-tab__cart-sub-right
fire({ order, detail, upload })