
const getContent = require('../lib/spider');
const cheerio = require('cheerio');
const toMarkdown = require('to-markdown');
const fs = require('fs');
const path = require('path');

exports.getGitDaily = function* () {
  var Cookie = 'SUHB=0Ryr9-FWsUMJP2; _T_WM=9999d45b15f34759ddbf410f183a9f6d; gsid_CTandWM=4uJa57b01vfgNxMxTcf5no2xv89; H5_INDEX_TITLE=; SUB=_2A257KP4GDeTxGeNJ6VsX8ynJyzmIHXVY0oJOrDV6PUJbrdANLXHukW2LVdDUCw8IUSpLWLuyLtRBDvZaMg..';

  var url = 'http://weibo.cn/GitHubDaily';
  var content = yield getContent(url, Cookie);
  var dir = path.dirname(__dirname)
  var file = path.join(dir, 'log/weibo.txt');
  var $ = cheerio.load(content);
  var title = $('.c .ctt').first().html();
  var titleStr = title.substring(0, 10);
  var fileContent = fs.readFileSync(file, 'utf-8');
  if (titleStr !== fileContent) {
    fs.writeFileSync(file, titleStr);
    var html = $('.c').first().html();
    return {
      text: title,
      desp: toMarkdown(html)
    };
  }
  return '';
};

@@ -292,67 +292,8 @@
 f6d;
- gsid_CTandWM=4uJa57b01vfgNxMxTcf5no2xv89; H5_INDEX_TITLE=;
  SUB
@@ -303,12 +303,12 @@
 A257
-KP4G
+MPX8
 DeTx
@@ -331,12 +331,12 @@
 HXVY
-0oJO
+2pu0
 rDV6
@@ -348,43 +348,85 @@
 dANL
-XHukW2LVdDUCw8IUSpLWLuyLtRBDvZaMg..
+VbjkW2YdM5mLj4JVbZdnGJ-ayw9GDRZBw..; gsid_CTandWM=4urrd0fb1tseAAFLGnxU8o2xv89
 ';%0A%0A
@@ -673,16 +673,104 @@
 html();%0A
+  if (!title) %7B%0A    return %7B%0A      text: 'Cookie%E5%A4%B1%E6%95%88',%0A      desp: '%E8%AF%B7%E6%9B%B4%E6%96%B0Cookie'%0A    %7D;%0A  %7D%0A
   var ti

update Cookie