Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 访问Airtable';使用Python进行分页';s请求库_Python 3.x_Api_Python Requests_Airtable - Fatal编程技术网

Python 3.x 访问Airtable';使用Python进行分页';s请求库

Python 3.x 访问Airtable';使用Python进行分页';s请求库,python-3.x,api,python-requests,airtable,Python 3.x,Api,Python Requests,Airtable,如何通过在url或查询中包含给定的偏移量来访问Airtable的分页 我在下面尝试将其包含在url中失败,错误为“KeyError:‘offset’” 我已经能够通过函数在_page()上访问第一个偏移量。为了简单起见,我从函数中获取结果并将其硬编码为变量offset_01 谢谢大家! import requests import pandas as pd offset_01 = 'itrCG3VDp2c34x1j1/recKTJGYMICe13iA8' url = 'https://api.

如何通过在url或查询中包含给定的偏移量来访问Airtable的分页

我在下面尝试将其包含在url中失败,错误为“KeyError:‘offset’”

我已经能够通过函数在_page()上访问第一个偏移量。为了简单起见,我从函数中获取结果并将其硬编码为变量offset_01

谢谢大家!

import requests
import pandas as pd

offset_01 = 'itrCG3VDp2c34x1j1/recKTJGYMICe13iA8'
url = 'https://api.airtable.com/v0/PRIVATETABLEKEY/accounts' + \
    '&offset=' + offset_01
headers = {'Authorization': 'Bearer PRIVATEAPIKEY'}


# Calling API
response = requests.get(
    url,
    headers=headers,
)
json_response = response.json()


# Finding AT page offset

def at_page(at_json):
    df_initial = pd.DataFrame(at_json)
    at_offset = df_initial['offset'][0]

    return at_offset

offset = at_page(json_response)
我想出来了:

正是params={'offset':'itrXXXXXX/recXXXXXX'}查询允许访问接下来的100条记录:

# Calling API
response = requests.get(
    url,
    headers=headers,
    params={'offset': 'itrXXXXXX/recXXXXXX'}
)
json_response = response.json()
希望这对别人有帮助。干杯