var CP_save = require("/lib/CP_save");
var md5 = require("md5");
const comments = [
  {
    comment_anonymous: "User 1",
    comment_title: "Название фильма 1",
    comment_text: "Текст комментария 1",
    comment_url: "/movie/id123456",
  },
  {
    comment_anonymous: "User 2",
    comment_title: "Название фильма 2",
    comment_text: "Текст комментария 2",
    comment_url: "/movie/id654321",
  },
];
comments.forEach((comment, i) => {
  let data = {};
  data.comment_anonymous = comment.comment_anonymous;
  data.comment_title = comment.comment_title;
  data.comment_text = comment.comment_text;
  data.comment_url = comment.comment_url;
  data.comment_ip = "127.0.0.1";
  data.comment_confirm = 1;
  data.comment_avatar =
    "/files/avatar/" + md5(comment.comment_anonymous) + ".svg";
  setTimeout(() => {
    CP_save.save(data, "comment", function (err) {
      if (err) return console.log(err);
      console.log("Комментарий " + i + " сохранен!");
    });
  }, 100 * i);
});const comments = [];
const cheerio = require("cheerio");
const axios = require("axios");
const startUrls = [
  "https://kinogo.biz/52866-doktor-strjendzh-i-multivselennaja-bezumija.html",
  "https://kinogo.cc/82551-doktor-strjendzh-i-multivselennaja-bezumija-2022.html",
];
// this might be called a "middleware" in scrapy.
const get = async (url) => {
  const response = await axios.get(url);
  return cheerio.load(response.data);
};
// this too.
const output = (item) => {
  comments.push(item);
};
// here is parse which is the initial scrapy callback
const parse = async (url) => {
  const $ = await get(url);
  output({
    comment_anonymous: "cosmos",
    comment_title: $("title").text(),
    comment_text: $(".comentarii").text(),
    comment_url: "/movie/id1219909",
  });
};
// and here is the main execution
startUrls.map((url) => parse(url));
console.log(comments);const comments = [];
const cheerio = require("cheerio");
const axios = require("axios");
const startUrls = [
  "https://kinogo.biz/52866-doktor-strjendzh-i-multivselennaja-bezumija.html",
  "https://kinogo.cc/82551-doktor-strjendzh-i-multivselennaja-bezumija-2022.html",
];
// this might be called a "middleware" in scrapy.
const get = async (url) => {
  const response = await axios.get(url);
  return cheerio.load(response.data);
};
// this too.
const output = (item) => {
  comments.push(item);
};
// here is parse which is the initial scrapy callback
const parse = async (url) => {
  const $ = await get(url);
  $('.comentarii').each((_, e) => {
      output({
        comment_anonymous: "cosmos",
        comment_title: $("title").text(),
        comment_text: $(e).text().replace(/(\s+)/g, ' '),
        comment_url: "/movie/id1219909",
      });
  });
  console.log(comments);
};
// and here is the main execution
startUrls.map((url) => parse(url)); 
	const comments = [];
const cheerio = require("cheerio");
const axios = require("axios");
const startUrls = [
  "https://kinogo.biz/52866-doktor-strjendzh-i-multivselennaja-bezumija.html",
  "https://kinogo.cc/82551-doktor-strjendzh-i-multivselennaja-bezumija-2022.html",
];
// this might be called a "middleware" in scrapy.
const get = async (url) => {
  const response = await axios.get(url);
  return cheerio.load(response.data);
};
// this too.
const output = (item) => {
  comments.push(item);
};
// here is parse which is the initial scrapy callback
const parse = async (url) => {
  const $ = await get(url);
  $('.comentarii').each((_, e) => {
      output({
        comment_anonymous: "cosmos",
        comment_title: $("title").text(),
        comment_text: $(e).text().replace(/(\s+)/g, ' '),
        comment_url: "/movie/id1219909",
      });
  });
  console.log(comments);
};
// and here is the main execution
startUrls.map((url) => parse(url));| Похожие темы | Раздел | Ответов | Дата | 
|---|---|---|---|
| Виджет комментариев | SEO | 2 | |
| Парсинг новостей | Контент | 4 | |
| Авто парсинг фильмов с api.themoviedb.org | Контент | 13 | 
