Open stiefin90 opened 6 years ago
I have also tried to modify width and height of the screenshot, but in any case, it seems that it recognize what you can see in the first picture as the entire desktop. I suppose that is a problem of my pc settings. I have a Dell Inspiron 13 5000 series
solved. I found the correct coordinates in this screenshot and modified the code. Now i have another problem. It works for most of question, but sometimes it gives me this error (bolded):
C:\Users\drist\Desktop\HQ-Trivia-Bot-master>node bot.js Screenshot done Answers resized node-tesseract: Running 'tesseract answers.jpg C:\Users\drist\AppData\Local\Temp\tmp-11224Jbepq1r3zSqR' node-tesseract: Deleting 'C:\Users\drist\AppData\Local\Temp\tmp-11224Jbepq1r3zSqR.txt' node-tesseract: Preprocessor cleanup Question resized node-tesseract: Running 'tesseract question.jpg C:\Users\drist\AppData\Local\Temp\tmp-11224igTYqY644nK1' node-tesseract: Deleting 'C:\Users\drist\AppData\Local\Temp\tmp-11224igTYqY644nK1.txt' node-tesseract: Preprocessor cleanup The question is "When used in cookbooks, maceration typically means doing what to food? " Wikipedia link found: https://en.wikipedia.org/wiki/Maceration_(food) C:\Users\drist\Desktop\HQ-Trivia-Bot-master\bot.js:58 if($('body').text().toLowerCase().indexOf(answers[0].toLowerCase()) != -1) { ^
TypeError: Cannot read property 'toLowerCase' of undefined
at Request._callback (C:\Users\drist\Desktop\HQ-Trivia-Bot-master\bot.js:58:94)
at Request.self.callback (C:\Users\drist\Desktop\HQ-Trivia-Bot-master\node_modules\request\request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.
Hi everybody, I follow the video istruction with attention and everything goes well, except for screenshots of question and answer. Here are tipical results:
Here is the first part of code:
`var screenshot = require('desktop-screenshot'); var gm = require('gm'); var nodecr = require('nodecr'); var google = require('google'); var request = require("request"); var cheerio = require('cheerio'); var question; var answers; var pointsAnswer0; var pointsAnswer1; var pointsAnswer2;
screenshot("screenshot.jpg", {width: 1600}, function(error, complete) { if(error) console.log("Screenshot failed", error); else console.log("Screenshot done"); gm('screenshot.jpg') .crop('337', '200', '448', '277') .write('answers.jpg', function (err) { if (!err) { console.log("Answers resized"); nodecr.process('answers.jpg',function(err, text) { if(err) { console.error(err); } else { answers = text.replace(/^\s*$[\n\r]{1,}/gm, ''); answers = answers.split(/\n/g); answers = answers.filter(function(e){ return e === 0 || e }); for(var i = 0; i < answers.length; i++) { console.log(answers[i]); } gm('screenshot.jpg') .crop('328','133', '451', '145') .write('question.jpg', function (err) { if (!err) { console.log("Question resized"); nodecr.process('question.jpg',function(err, text) { if(err) { console.error(err); } else { question = text.replace(/\n/g, " "); console.log('The question is "' + question + '"'); google.resultsPerPage = 25; var nextCounter = 0;`