I am needing to update the query part (page_index=) of a URL. I have tried a couple ways shown below but am hitting a wall. I am new to python and looking for guidance. The page index ranges from 0 - 511 (adds new daily) and I need to update the url to loop through all of the indexes. The index will always start at 0.
import urlparse
url = 'https://api.appannie.com/v1.2/apps/ios/app/331177714/reviews?
start_date=2016-1-01&end_date=2017-8-26&page_index=0&countries=US'
parts = urlparse.urlparse(url)
parts = parts._replace(query = page_index [2])
parts.geturl()
I get the error:
TypeError Traceback (most recent call last)
<ipython-input-29-066332f37bb3> in <module>()
3 url = 'https://api.appannie.com/v1.2/apps/ios/app/331177714/reviews?start_date=2016-1-01&end_date=2017-8-26&page_index=0&countries=US'
4 parts = urlparse.urlparse(url)
----> 5 parts = parts._replace(query = page_index [2])
6 parts.geturl()
7
TypeError: 'function' object has no attribute '__getitem__'