<commit_before>'use strict';

const EventEmitter = require('events');
const url = require('url');
const _ = require('lodash');

module.exports = class BitecoinNews extends EventEmitter {
  constructor(crawler) {
    super();
    this._targetUrl =
      'http://www.bitecoin.com/online/category/%E6%AF%94%E7%89%B9%E5%B8%81';
    this._crawler = crawler;
  }

  async start(current) {
    this._crawler.queue([
      {
        uri: this._targetUrl,
        headers: {
          Accept:
            'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
          'Accept-Encoding': 'gzip, deflate',
          'Accept-Language': 'zh-CN,zh;q=0.8',
          'Cache-Control': 'max-age=0',
          Connection: 'keep-alive',
          Cookie: 'PHPSESSID=f4b6mkf3hlobbvpg7d5por8nq6',
          Host: 'www.bitecoin.com',
          'Upgrade-Insecure-Requests': 1,
          'User-Agent':
            'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36'
        },
        callback: async (err, res, done) => {
          if (err || res.statusCode !== 200) {
            this.emit('error', err || res.statusCode);
            return done();
          }

          const $ = res.$;
          const notices = [];
          let maxIndex = current;

          $('.newslist').find('.excerpt').each((i, el) => {
            const titleEl = $(el).find('h2').find('a');
            const href = new url.URL(titleEl.attr('href'));
            const last = +_.replace(
              _.last(href.pathname.split('/')),
              '.html',
              ''
            );
            const title = _.trim(_.replace(titleEl.text(), '/r/n', ''));

            notices.push({
              title: title,
              time: null,
              url: href.toString()
            });

            maxIndex = last;
          });<commit_msg>fix logic<commit_after>'use strict';

const EventEmitter = require('events');
const url = require('url');
const _ = require('lodash');

module.exports = class BitecoinNews extends EventEmitter {
  constructor(crawler) {
    super();
    this._targetUrl =
      'http://www.bitecoin.com/online/category/%E6%AF%94%E7%89%B9%E5%B8%81';
    this._crawler = crawler;
  }

  async start(current) {
    this._crawler.queue([
      {
        uri: this._targetUrl,
        headers: {
          Accept:
            'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
          'Accept-Encoding': 'gzip, deflate',
          'Accept-Language': 'zh-CN,zh;q=0.8',
          'Cache-Control': 'max-age=0',
          Connection: 'keep-alive',
          Cookie: 'PHPSESSID=f4b6mkf3hlobbvpg7d5por8nq6',
          Host: 'www.bitecoin.com',
          'Upgrade-Insecure-Requests': 1,
          'User-Agent':
            'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36'
        },
        callback: async (err, res, done) => {
          if (err || res.statusCode !== 200) {
            this.emit('error', err || res.statusCode);
            return done();
          }

          const $ = res.$;
          const notices = [];
          let maxIndex = current || 0;

          $('.newslist').find('.excerpt').each((i, el) => {
            const titleEl = $(el).find('h2').find('a');
            const href = new url.URL(titleEl.attr('href'));
            const last = +_.replace(
              _.last(href.pathname.split('/')),
              '.html',
              ''
            );

            if (last > current) {
              const title = `【比特币中文网】 ${_.trim(
                _.replace(titleEl.text(), '/r/n', '')
              )}`;

              notices.push({
                title: title,
                time: null,
                url: href.toString()
              });

              maxIndex = last;
            }
          });
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.029396728016359917, 'mean_word_length': 1.7556338028169014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4069155', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1257, 'n_words': 213}