火车头采集器,内容采集规则中出现时间戳格式的,选择 数据处理—高级功能—运行C#代码
public string Run(string content,ResponseEntry response){
ulong a = ulong.Parse(content);
content = GetDateTimeFrom1970Ticks(a).ToString();
return content;
}
public static String GetDateTimeFrom1970Ticks(ulong curSeconds)
{
DateTime nowTime;
if (curSeconds.ToString().Length == 13)
{
nowTime = new DateTime(1970, 1, 1, 8, 0, 0).AddMilliseconds(curSeconds);
}
else
{
nowTime = new DateTime(1970, 1, 1, 8, 0, 0).AddSeconds(curSeconds);
}
return nowTime.ToString();
}
点个关注,不定期的发布有关采集器的文章和我的技巧。