I'm working on a script that will scrape any answers to my questions using DuckDuckGo! I tried doing this using DuckDuckGo's API, and it kind of works as well but the result gives a ton of info.. Is there any method to limit it's sentences? Like to 3 sentences or 4 senteces? this is my script till now:
word = input("Enter the Word: ")
query = f"what is {word}?"
r = requests.get("https://api.duckduckgo.com",
params = {
"q": query,
"format": "json"
})
data = r.json()
print(data["Abstract"])
What Output I get:
Enter the Word: Artificial Intelligence
Artificial intelligence is intelligence demonstrated by machines, as opposed to natural intelligence displayed by animals including humans. Leading AI textbooks define the field as the study of "intelligent agents": any system that perceives its environment and takes actions that maximize its chance of achieving its goals. Some popular accounts use the term "artificial intelligence" to describe machines that mimic "cognitive" functions that humans associate with the human mind, such as "learning" and "problem solving", however, this definition is rejected by major AI researchers. AI applications include advanced web search engines, recommendation systems, understanding human speech, self-driving cars, automated decision-making and competing at the highest level in strategic game systems. As machines become increasingly capable, tasks considered to require "intelligence" are often removed from the definition of AI, a phenomenon known as the AI effect.
I want it to Just print a starting few sentences(i.e: Only the first 3 or 4 sentences.)