fetch_data.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:twitter_caption 作者: tencia 项目源码 文件源码
def fetchsamples(limit):
  ret = []
  url = "https://stream.twitter.com/1/statuses/sample.json"
  parameters = []
  while len(ret) < limit:
      try:
          response = twitterreq(url, "GET", parameters)
          for line in response:
            ret.append(line.strip())
            if len(ret) % 100 == 0:
                print len(ret)
            if len(ret) >= limit:
              break
      except IncompleteRead:
          pass
      except BadStatusLine:
          pass
  return ret

# filter tweets for images / good captions and output them to file
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号