Quantcast
Channel: Questions in topic: "httpwebrequest"
Viewing all articles
Browse latest Browse all 190

How do I get into the data returned from a UnityWebRequest ?

$
0
0
I used the example from the unity manual and threw in more Debug.Log lines to show status: IEnumerator GetText() { UnityWebRequest www = new UnityWebRequest("https://www.investopedia.com/markets/api/partial/historical/?Symbol=SPY&Type=Historical+Prices&Timeframe=Daily&StartDate=Dec+31%2C+2018"); www.downloadHandler = new DownloadHandlerBuffer(); yield return www.SendWebRequest(); Debug.Log("TickerScraper.GetText " + www.isNetworkError + " " + www.isHttpError); if (www.isNetworkError || www.isHttpError) { Debug.Log("TickerScraper.isNetworkError"); Debug.Log(www.error); } else { // Show results as text Debug.Log("TickerScraper.downloadHandler.text"); Debug.Log(www.downloadHandler.text); // Or retrieve results as binary data byte[] results = www.downloadHandler.data; } And the isNet and isHttp erros are flase so the request looks like it worked. I can not find any examples of how to get to the text data itself. There are two data lines past the headings on the page: > Date Open High Low Adj. Close Volume Jan 02, 2019 13.80 14.55 13.61 14.37 14,862,962
Dec 31, 2018 14.23 14.25 13.64 14.03 7,636,510
The log shows :
01-03 23:23:54.938: I/Unity(10070): TickerScraper.downloadHandler.text
01-03 23:23:54.938: I/Unity(10070): c__Iterator0:MoveNext() (at C:\Users\User\Documents\UnityProjects\Project\Assets\TickerScraper.cs:33)
So I am very excited this worked. I am using this page because of the low text bytes count. I have other larger web pages I will be requesting from. Just wanted to keep it simple at first.
In further research I found this line:
if (result != null) result(www.downloadHandler.text);
But how is result then accessed or displayed?
Any help would be appreciated. Thanks in advance.

Viewing all articles
Browse latest Browse all 190

Trending Articles