mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
updated sinastock_spider: time zone adjustment
This commit is contained in:
@@ -5,9 +5,13 @@ from datetime import datetime
|
||||
|
||||
import scrapy
|
||||
from pymongo import MongoClient
|
||||
import pytz
|
||||
|
||||
from sinastock.items import NewsItem
|
||||
|
||||
# 时区
|
||||
tz = pytz.timezone('Asia/Shanghai')
|
||||
|
||||
|
||||
class SinastockSpiderSpider(scrapy.Spider):
|
||||
name = 'sinastock_spider'
|
||||
@@ -57,5 +61,7 @@ class SinastockSpiderSpider(scrapy.Spider):
|
||||
if item['text'] is None or item['ts_str'] is None:
|
||||
pass
|
||||
else:
|
||||
item['ts'] = datetime.strptime(item['ts_str'], '%Y年%m月%d日 %H:%M')
|
||||
ts = datetime.strptime(item['ts_str'], '%Y年%m月%d日 %H:%M')
|
||||
ts = tz.localize(ts)
|
||||
item['ts'] = ts
|
||||
yield item
|
||||
|
||||
Reference in New Issue
Block a user