oop-labs-collection/labs/3/lab3lib/fetchContent.py

11 lines
262 B
Python

import requests
from random import randint
import json
r = requests.get("http://10.1.1.2:8080/search?q=test&format=json&language=en-US")
results = json.loads(r.text)["results"]
final_content = results[randint(0, len(results))]['content']
print(final_content)