Open mingjun1120 opened 2 years ago
@sweemeng Do you face this issue when you?
I introduced a parameter called pages. I didn't put it in the docs. https://github.com/sweemeng/cuaca/blob/master/cuaca/api.py#L86
locations(self, location_type, page=0)
. I don't know how many page exist, but i put a big number and it returns empty.
In short, try.
page = 0
districts = api.locations("DISTRICT", page)
you will have to use a while loop to generate the page you need. See if the API make sense. It start from page 0, so i default it to 0
The default amount is 50, so in page 2, it should have the next 50. It just makes the math easier to deal with
I see. Thanks for updating me. Since we don't know the maximum amount of DISTRICTS and TOWNS available, we can keep looping to retrieve all the districts and towns available until throw an exception. Then, just wrap it with try except to solve the problem. I will try this way tmr and update you.
On Wed, Aug 10, 2022, 19:52 sweemeng @.***> wrote:
The default amount is 50, so in page 2, it should have the next 50. It just makes the math easier to deal with
— Reply to this email directly, view it on GitHub https://github.com/sweemeng/cuaca/issues/14#issuecomment-1210567039, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5A4AAFCRDSPKA5KQTAEGLVYOJXLANCNFSM56D3LU5A . You are receiving this because you authored the thread.Message ID: @.***>
When I tried to pass in "DISTRICT" or "TOWN" as an argument into the
api.locations()
function, it cannot retrieve all of the districts as well as towns of each state. Below are outputs that I received when I call this function by passing "DISTRICT" and "TOWN" as arguments:Output:
Output: