node爬虫验证码问题
在使用谷歌的puppeteer登录有道云时碰到的验证码问题
const puppeteer = require('puppeteer');
var tesseract = require('tesseract.js');
const account = `[email protected]`;
const password = `xxx`;
function sleep(time) {
return new Promise(resolve => {
setTimeout(() => { resolve() }, time)
})
}
(async () => {
// const browser = await puppeteer.launch();//打开浏览器
const browser = await puppeteer.launch({ headless: false });//打开有界面的浏览器
const page = await browser.newPage();//打开一个空白页
await page.goto('https://note.youdao.com/signIn/index.html', { waitUntil: "networkidle0" });//打开豆瓣网站
await page.type('.login-username', account);
await page.type('.login-password', password);
await page.click('.login-btn');
await sleep(1000)
await page.setRequestInterception(true);
page.on('request', async request => {
let url = await request.url()
console.log(url);
if (url.indexOf('login/acc/urs/verify/') !== -1) {
console.log(145, url)
let text = await tesseract.recognize(url)
//error
console.log("res", text)
}
request.continue();
})
await page.click('.reload-vcode-button');
})();
执行到 //error这一步的时候 url是正确打印的 url是固定的’https://note.youdao.com/login/acc/urs/verify/get?product=YNOTE&width=80&height=32&rc=0.21622443251003398’ 但在浏览器里每次刷新都是不一样的验证码 tesseract.recognize(url)解析的时候返回的就是text就是空字符串
大佬们 我该怎么通过这个验证码