Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Request 100 repositories per page (and only their slugs), and the next page URL
- next_page_url = 'https://api.bitbucket.org/2.0/repositories/%s?pagelen=100&fields=next,values.slug' %team
- # Keep fetching pages while there's a page to fetch
- full_repo_list = []
- while next_page_url is not None:
- response = requests.get(next_page_url, auth=(username, password))
- print ("response> %s" %response)
- page_json = response.json()
- print ("page_json> %s" %page_json)
- # Parse repositories from the JSON
- for repo in page_json['values']:
- full_repo_list.append(repo['slug'])
- # Get the next page URL, if present
- # It will include same query parameters, so no need to append them again
- next_page_url = page_json.get('next', None)
- # Result length will be equal to `size` returned on any page
- print ("Result: \n", len(full_repo_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement