oop-labs-collection/labs/5/lab5lib/fetchContent.py

11 lines
262 B
Python
Raw Normal View History

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)