How To paginated Requests With Python Request In Shopify REST API?

I am using the following code to get orders

import shopify
import requests
import pandas as pd
key = 'key'
secret='secret'
shopify.Session.setup(api_key=key, secret=secret)
final=pd.DataFrame()

url="https://key:secret@mystore.myshopify.com/admin/api/2023-07/orders.json"
params={'created_at_min':'2023-01-01 00:00:00',
       'created_at_max':'2023-06-30 23:59:59'}

headers = {'content': 'key'}
r = requests.get(url=url,params=params, headers=headers)
a=r.json()
df=pd.DataFrame(a['orders'])

But I couldn’t figure out how to get the data from the next page. shopify is not returning any response header.

I can get max 250 orders in a single query. But how do I do this if I need to receive more than 250 orders ?

My solution was to use the last_id parameter.

url = ('%s/orders.json?status=any&limit=250&last_id=%s' %(shop_url, last_id))

And then running a loop calling a request with an updated last_id for each loop.