0

BotoPython用の公式AmazonAPIモジュールのようですが、これはTornado用であるため、ここに私の質問があります。

  • それはページネーションを提供しますか(Amazonはページごとに10の製品を提供するので、10の製品のみを要求します、それから私は最初のページだけを取得したいです...)、そしてどのように(サンプルコード?)
  • 次に、製品の解析方法を解析します。python-amazon-simple-product-apiを使用しましたが、残念ながらページネーションが提供されないため、すべての提供が繰り返されます。
4

1 に答える 1

3

通常、ページ付けは、APIを要求するクライアントによって実行されます。botoでこれを行うには、システムを切断する必要があります。たとえば、get_all_instances defを使用して、boto経由でAWSを呼び出すとします。それらを何らかの方法で保存してから、表示されているサーバーと表示されていないサーバーを追跡する必要があります。私の知る限り、botoには、ほとんどの開発者がMySQLから使用しているLIMIT機能がありません。個人的には、すべてのインスタンスをスキャンして、次のようにmongoに格納します。

for r in conn.get_all_instances():        # loop through all reservations
   groups = [g.name for g in r.groups]    # get a list of groups for this reservation
   for x in r.instances:                  # loop through all instances with-in reservation
      groups = ','.join(groups)         # join the groups into a comma separated list 
      name = x.tags.get('Name','');       # get instance name from the 'Name' tag

      new_record = { "tagname":name, "ip_address":x.private_ip_address, 
                      "external_ip_nat":x.ip_address, "type":x.instance_type,
                      "state":x.state, "base_image":x.image_id, "placement":x.placement, 
                      "public_ec2_dns":x.public_dns_name,
                      "launch_time":x.launch_time, "parent": ObjectId(account['_id'])}
      new_record['groups'] = groups
      systems_coll.update({'_id':x.id},{"$set":new_record},upsert=True)
      error = db.error()
      if error != None:
           print "err:%s:" % str(error)

これらをtry/catchブロックでラップすることもできます。君による。ボトからそれらを取り出したら、カットアップ作業を行うのは簡単なはずです。

-ジェス

于 2012-10-27T17:48:24.433 に答える