代码:
# coding=utf-8 import shutil from textwrap import indent import traceback import os import base64 import json import requests from pprint import pprint from urllib.request import urlopen import os import csv import json # Init url = "https://www.xacisco.net/blog/wp-json/wp/v2/posts?_fields=id,link" username = "xxx" password = "xxx" credentials = "{}:{}".format(username, password) token = base64.b64encode(credentials.encode()) r=requests.get(url) print(json.dumps(r.json(),indent=4))