Skip to content

Instantly share code, notes, and snippets.

@davidshq
Created May 14, 2018 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidshq/542f50abb80c68b4fcfef6fc0e5a2124 to your computer and use it in GitHub Desktop.
Save davidshq/542f50abb80c68b4fcfef6fc0e5a2124 to your computer and use it in GitHub Desktop.
WOPAS Actuall Pull from API
import requests
import os.path
import html
import sys
import time
import pdb
import json
# Calls WP API to get page of Plugin Results, also returns last_page so we can
# terminate our loop when we have all our data
def get_plugin_info_page(page_number, plugins_per_page, plugins_order, multiple_files):
# Added the per_page param to the endpoint so we can get more results per request
# Each request will also take longer, so we're slowing down our rate a bit
url = 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins& \
request[per_page]={}&request[browse]={}&request[page]={}&request[fields][description]=0&request[fields][sections]=0'.format(plugins_per_page, plugins_order, page_number)
response = requests.get(url)
json_data = response.json()
num_pages = json_data['info']['pages']
plugins = json_data['plugins']
return plugins, num_pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment