⾃⼰编写⼩⽶⼿机⾃动购买脚本(仅供个⼈学习不要商业使⽤)⾃⼰尝试⽤⽆头浏览器编写购买脚本效果如下:
后续可以深度开发使⽤
const puppeteer = require('puppeteer');
const config = {
user: '⾃⼰⽤户名',
password: '⾃⼰密码',
}
设计院实习总结function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
(async () => {
const browser = await puppeteer.launch({
headless: false,
defaultViewport: {
width: 1920,
height: 1080
}
});
const page = wPage();
// Login
('account.xiaomi/',{
waitUntil:'domcontentloaded'
});
await page.waitForSelector('input[name="account"]')大学学生会申请书
pe('input[name="account"]', String());
pe('input[name="password"]', config.password);
await page.click('button[type = "submit"]')
const page2 = wPage();
('www.mi/buy/detail?product_id=12511', {
waitUntil: 'domcontentloaded'
});
await page2.waitForSelector('.sale-btn')
await page2.click('.sale-btn')
/
/ await page.waitFor(1000);
// await page2.waitForSelector('.sale-btn')
// await page2.click('.sale-btn')
/* await page2.waitForSelector('.btn-primary')
await page2.click('.btn-primary') */
const page3 = wPage();
('www.mi/buy/cart', {
waitUntil: 'domcontentloaded'
});
await page3.waitForSelector('.btn-primary')
windows10安装密钥await page3.click('.btn-primary')
await page3.waitForSelector('.el-dialog__footer .btn-primary')
await page3.click('.el-dialog__footer .btn-primary')
await page3.waitForSelector('.btn-primary')沪港通开户
无聊干什么好await page3.click('.btn-primary')
await page3.waitForSelector('.total-price .btn-primary')
await page3.click('.total-price .btn-primary')
const page4 = wPage();
('www.mi/buy/checkout', {
waitUntil: 'domcontentloaded'
});
await page4.waitForSelector('.address-item')
await page4.click('.address-item')
await page4.waitForSelector('.address-item')
await page4.click('.address-item')
await page4.waitForSelector('.operating-button a')
await page4.click('.operating-button a')
})();
春天在哪里的歌词 新的测试框架
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论