AnsweredAssumed Answered

Pagination makes endless api calls when retrieving page_views

Question asked by Erkan Er on Sep 14, 2017
Latest reply on Feb 10, 2018 by James Jones

I have the following code to retrieve page views of the user with id=123456. The very same code works when I retrieve the entries of a user for a discussion forum. However, when I change the uri to to retrieve the page views, no matter what the page number is, it continues to return the same records over and over again. So, there is no further data maybe, but it continues to retrieve data. That is, it creates an endless while loop. I wonder if you see any problems with the code:




while control==0:

uri = '' + str(npagina)

r = requests.get(uri, headers=headers)

raw = r.json()  #if no new data, then continues to retrieve duplicate data

if raw != "":

    views = pd.DataFrame(raw)

    if 'id' in views.columns:


          page_views = page_views.append(views)


          control = 1