check if phpbb is installed
This commit is contained in:
parent
2c7f1a8e56
commit
12fe66e790
27
urq.js
27
urq.js
|
@ -51,11 +51,6 @@ export default class Urq {
|
|||
this.db = await mysql.createConnection(this.dbopts);
|
||||
this.browser = await puppeteer.launch({
|
||||
"headless": true,
|
||||
"args": [
|
||||
"--disable-web-security",
|
||||
"--no-sandbox",
|
||||
"--disable-dev-shm-usage"
|
||||
]
|
||||
});
|
||||
await this.db.execute(`
|
||||
CREATE TABLE IF NOT EXISTS \`${config.DB_PREFIX}bordathreads\` (
|
||||
|
@ -64,7 +59,17 @@ export default class Urq {
|
|||
\`name\` Varchar(255) NOT NULL,
|
||||
PRIMARY KEY ( \`id\` )
|
||||
);`);
|
||||
// await this.scrape_pages();
|
||||
try {
|
||||
let [threadrow, fields] = await this.db.execute(
|
||||
`SELECT COUNT(*) FROM \`${config.DB_PREFIX}posts\``
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('Please install phpbb first.');
|
||||
await this.browser.close();
|
||||
return;
|
||||
}
|
||||
|
||||
await this.scrape_pages();
|
||||
await this.scrape_threads();
|
||||
await this.browser.close();
|
||||
};
|
||||
|
@ -107,12 +112,20 @@ export default class Urq {
|
|||
|
||||
for (let i = 0; i < threads.length; i++) {
|
||||
try {
|
||||
let [rows, fields] = await this.db.execute(`
|
||||
let [threadrow, fields] = await this.db.execute(`
|
||||
SELECT \`id\` FROM \`${config.DB_PREFIX}bordathreads\`
|
||||
WHERE \`url\` = ?
|
||||
`,[
|
||||
threads[i].url,
|
||||
]);
|
||||
if (threadrow.length === 0) {
|
||||
let [rows, fields] = await this.db.execute(`
|
||||
INSERT INTO ${config.DB_PREFIX}bordathreads (url, name) VALUES( ?, ? )
|
||||
`, [
|
||||
threads[i].url,
|
||||
threads[i].name,
|
||||
]);
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue