weiboSpider icon indicating copy to clipboard operation
weiboSpider copied to clipboard

时区问题

Open jerrylaikr opened this issue 3 years ago • 1 comments
trafficstars

因为没找到相关的issue所以感觉不是很紧要的问题,后续有需要我再整理详细的信息。

我自己基于此项目二次开发魔改的时候有几次遇到时区错乱的问题,个人感觉主要是PageParser.get_publish_time()方法利用相对时间转换成绝对时间造成的。如果系统时区是UTC那么爬取到最近发布的微博,发布时间都会变成UTC,如果系统时区是北京时间则会保存北京时间。

我在网页端也没找到什么办法可以强制显示绝对时间,在爬虫代码中试图统一了一下时区,凑合着是能稳定一些些,但是修改过程太混乱导致整个branch严重spaghetti code化。

综上所述,我瞎改的就不太好提交PR了,感觉可以讨论一下有些什么可能的解决思路。

以下是最近爬的内容,因为魔改了很多代码,所以无法保证能在原生版本中复现: image image

这两条实际发布时间间隔不到一小时,爬取图一的系统时区是UTC,而图二的系统时区是北京时间。

jerrylaikr avatar Sep 16 '22 05:09 jerrylaikr

感谢建议。

非常细心的建议。我的想法是如果想统一时区,可以先获取系统时区,然后根据系统时区和我们想要的标准时区,把微博时间转换成标准的。这是我的想法,最近没办法调试,不确定是否可行。

dataabc avatar Sep 16 '22 13:09 dataabc

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 22 '22 21:11 stale[bot]

Closing as stale, please reopen if you'd like to work on this further.

stale[bot] avatar Dec 16 '22 04:12 stale[bot]