当前位置: 首页>>代码示例>>Python>>正文


Python Arrow.strptime方法代码示例

本文整理汇总了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)
开发者ID:ssheftel,项目名称:gtj-events-scraper,代码行数:17,代码来源:event_scraper.py

示例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)
开发者ID:Vaayne,项目名称:vaayne.com,代码行数:34,代码来源:wx.py

示例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 = []
开发者ID:harej,项目名称:sigmabot,代码行数:30,代码来源:archiver.py

示例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)
开发者ID:Vaayne,项目名称:vaayne.com,代码行数:30,代码来源:smzdm.py

示例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
开发者ID:Vaayne,项目名称:vaayne.com,代码行数:5,代码来源:wx_iwgc.py

示例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")
开发者ID:scholer,项目名称:ceterach,代码行数:5,代码来源:utils.py


注:本文中的arrow.Arrow.strptime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。