本文整理汇总了Python中arrow.Arrow.strptime方法的典型用法代码示例。如果您正苦于以下问题:Python Arrow.strptime方法的具体用法?Python Arrow.strptime怎么用?Python Arrow.strptime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arrow.Arrow
的用法示例。
在下文中一共展示了Arrow.strptime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_dates
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import strptime [as 别名]
def _process_dates(self):
"""internal method to parse the gcal_url for start and end date info and
set the _start_date_arrow and _end_date_arrow to instances of arrow objs
"""
#dont rerun if _start_date_arrow or _end_date_arrow is set or if gcal_url not found
if (self._start_date_arrow or self._end_date_arrow) or not self.gcal_url: return
gcal_url = self.gcal_url
gcal_url_date_time_match = self.gcal_url_date_time_pattern.search(gcal_url)
if not gcal_url_date_time_match: return
(gcal_url_start_date_str, gcal_url_end_date_str) = gcal_url_date_time_match.groups()
# add time to date if no time spesified
if 'T' not in gcal_url_start_date_str: gcal_url_start_date_str += 'T000000'
if 'T' not in gcal_url_end_date_str: gcal_url_end_date_str += 'T000000'
self._start_date_arrow = Arrow.strptime(gcal_url_start_date_str, self.gcal_url_date_time_format, tzinfo=self.event_timezone)
self._end_date_arrow = Arrow.strptime(gcal_url_end_date_str, self.gcal_url_date_time_format, tzinfo=self.event_timezone)
示例2: run
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import strptime [as 别名]
def run(self, symbol):
uid = self.get_uuid(symbol)
if uid is None:
return
url = 'http://www.newrank.cn/xdnphb/detail/getAccountArticle'
params = {
'uuid': uid,
}
r = self.req_post(url, data=params)
datas = r.json()
try:
infos = datas['value']['lastestArticle']
for info in infos:
source_url = self.parse_url(info.get('url'))
if self.repeat_check(source_url):
continue
title = info.get('title')
wx_id = info.get('account')
author = info.get('author')
post_time = info.get('publicTime')
post_time = Arrow.strptime(post_time, '%Y-%m-%d %H:%M:%S', tzinfo='Asia/Shanghai').timestamp
summary = info.get('summary')
content, img = self.get_content(source_url)
if info.get('imageUrl') is None:
image = img
else:
image = info.get('imageUrl')
self.add_result(title=title, author=author, post_time=post_time, source_name=author,
source_url=source_url, summary=summary, spider_name=self.spider_name,
content=content, image=image, category=self.category, aid=wx_id)
except Exception as e:
self.log.error(e)
示例3: parse_stamps
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import strptime [as 别名]
def parse_stamps(self, expr=STAMP_RE, fmt='%H:%M, %d %B %Y (%Z)'):
stamps = []
algo = self.archiver.config['algo']
try:
maxage = str2time(re.search(r"^old\((\w+)\)$", algo).group(1))
except AttributeError as e:
e.args = ("Malformed archive algorithm",)
raise ArchiveError(e)
for thread in self.threads:
if mwp_parse(thread['header']).get(0).level != 2:
# the header is not level 2
stamps = []
continue
for stamp in expr.finditer(thread['content']):
# This for loop can probably be optimised, but ain't nobody
# got time fo' dat
#if stamp.group(1) in MONTHS:
try:
stamps.append(Arrow.strptime(stamp.group(0), fmt))
except ValueError: # Invalid stamps should not be parsed, ever
continue
if stamps:
# The most recent stamp should be used to see if we should archive
most_recent = max(stamps)
thread['stamp'] = most_recent
thread['oldenough'] = Arrow.utcnow() - most_recent > maxage
pass # No stamps were found, abandon thread
stamps = []
示例4: parse
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import strptime [as 别名]
def parse(self, kind, aid, summary):
url = 'http://api.smzdm.com/v1/%s/articles/%s' % (kind, aid)
if self.blf.exist(url):
return
self.blf.add(url)
try:
r = self.req_get(url)
data = r.json().get('data')
title = data.get('article_title')
author = data.get('article_referrals')
post_time = data.get('article_date')
post_time = Arrow.strptime(post_time, '%Y-%m-%d %H:%M:%S', tzinfo='Asia/Shanghai').timestamp
source_url = data.get('article_url')
# summary = data.get('summary')
content = data.get('article_filter_content')
try:
content = self.get_img(BeautifulSoup('<div>%s</div>' % content, 'lxml'), 'src')
except Exception as e:
self.log.exception(e)
image = data.get('article_pic')
# self.add_result(title=title, author=author, post_time=post_time, source_name=self.spider_name,
# source_url=source_url, summary=summary,
# content=content, image=image, category=self.category, aid=kind)
self.add_result(title=title, author=author, post_time=post_time, source_name='什么值得买',
source_url=source_url, summary=summary, spider_name=self.spider_name,
content=content, image=image, category=self.category, aid=kind)
except Exception as e:
self.log.error(e)
示例5: parse_time
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import strptime [as 别名]
def parse_time(time_str):
t = ct.search(time_str).group(0)
return Arrow.strptime(t, '%Y-%m-%d %H:%M:%S', tzinfo='Asia/Shanghai').timestamp
示例6: isostrptime
# 需要导入模块: from arrow import Arrow [as 别名]
# 或者: from arrow.Arrow import strptime [as 别名]
def isostrptime(stamp):
"""I'm lazy, and can never remember the format string"""
return Arrow.strptime(stamp, "%Y-%m-%dT%H:%M:%SZ")