I found that it has to be plaintext
instead of plainText
.
At least in example with pod
and subpod
it works.
Maybe portal WolframAlpha
changed this name in results and now module wolfram
has to change it in documentation.
But I don't know why it doesn't work with next(res.results).plaintext
. maybe problem is different. Maybe it needs other changes in module.
BTW: you can use next(res.results).keys()
to see if it has field plaintext
import os
import wolframalpha
APP_ID = "your-app-id"
#APP_ID = os.getenv("WOLFRAMALPHA_TOKEN")
#print(APP_ID)
#query = "temperature in Washington, DC on October 3, 2012"
query = "what is the temperature in georgia"
client = wolframalpha.Client(APP_ID)
res = client.query(query)
for pod in res.pods:
print('title:', pod.title)
for sub in pod.subpods:
print()
print(sub.plaintext)
print('\n---\n')
Result:
title: Input interpretation
temperature | center of the State of Georgia
---
title: Result
16 °C
(41 minutes ago)
---
title: History & forecast
| | |
low: -4 °C
Sat, Dec 26, 7:00am | average high: | 13 °C
average low: | 1 °C | high: 16 °C
Tue, Dec 29, 4:00pm
| |
---
title: Weather station information
name | KWRB (Robins AFB)
relative position | 13 km W (from center of the State of Georgia)
relative elevation | (comparable to center of the State of Georgia)
local time | 4:36:35 pm EST | Sunday, December 27, 2020
local sunlight | sun is above the horizon
azimuth: 234° (SW) | altitude: 10° ()
---
title: Weather station comparisons
| position | elevation | current temperature
KWRB | 13 km W | 90 m | 16 °C (41 minutes ago)
KMCN | 19 km WNW | 110 m | 16 °C (44 minutes ago)
KDBN | 45 km ESE | 94 m | 16 °C (42 minutes ago)
(sorted by distance and inferred reliability)
---