Archived
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from time import sleep
|
|
|
|
import requests
|
|
import json
|
|
|
|
from tqdm import tqdm
|
|
|
|
starting_page = 1
|
|
request_per_page = 100
|
|
response = requests.get(f"https://api.wordpress.org/plugins/info/1.2/?action=query_plugins"
|
|
f"&request[page]={starting_page}"
|
|
f"&request[per_page]={request_per_page}")
|
|
response_json = response.json()
|
|
# print(response_json)
|
|
|
|
page_no = response_json['info']['pages']
|
|
plugins_info_list = []
|
|
plugins_info_str = ""
|
|
for i in tqdm(range(page_no)):
|
|
response = requests.get(f"https://api.wordpress.org/plugins/info/1.2/?action=query_plugins"
|
|
f"&request[page]={i+1}"
|
|
f"&request[per_page]={request_per_page}")
|
|
response_json = response.json()
|
|
plugins_info_list.append(response_json['plugins'])
|
|
# plugins_info_str += str(response_json['plugins'])
|
|
sleep(0.1)
|
|
|
|
flattened_list = [item for sublist in plugins_info_list for item in sublist]
|
|
|
|
plugins_info_json = json.dumps(flattened_list, indent=4)
|
|
print(plugins_info_json)
|
|
|
|
filename = "output.json"
|
|
|
|
# Open the file in write mode ('w') and use json.dump() to write the data
|
|
with open(filename, 'w') as f:
|
|
f.write(plugins_info_json) |