作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为什么不起作用?我想下载txt并保存在数据库中。
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'a/ innego komunikatora. Z góry, wielkie dzięki. Temat będzie aktualizowany w m' at line 1
var cheerio = require('cheerio');
const request = require('request');
var mysql = require('mysql');
var con = mysql.createConnection({
password..
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
let x=1;
function downlad(){
x++;
request.get(`http://wklejto.pl/638151`, (err, response, body) => {
console.log(response.statusCode);
const $=cheerio.load(
body,
{ decodeEntities: false });
const el = $('.de1').html();
con.query("INSERT INTO `wklejki` (`ID`, `txt`) VALUES (NULL, '"+el+"');");
console.log(el);
});
}downlad();
最佳答案
替换
con.query("INSERT INTO `wklejki` (`ID`, `txt`) VALUES (NULL, '"+el+"');");
与
con.query('INSERT INTO wklejki SET ?', {ID: null, txt: el}, function (error, results, fields) {
//Whatever you want to do next.
});
关于mysql - ER_PARSE_ERROR : You have an error in your SQL syntax;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56543121/
我是一名优秀的程序员,十分优秀!