Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
170 views
in Technique[技术] by (71.8m points)

c# - www.text not showing complete data in android

I'm using the following code to get the text from a web page:

    private IEnumerator FetchText() {
        WWW www = new WWW(URL);

        yield return www;

        if(www.error == null) {
            myText.text = www.text.Length.ToString();
        }
        ...
    }

When I run this in Unity, I get 185616 characters long string. But when I run this in android device, I get only 47133 characters. Is it because that web page behaves differently in Windows and Android? If yes, how can I fetch the same content from android as I'd be getting from desktop PC.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's possible that the URL you are trying to fetch is detecting your user agent and sending you to some kind of mobile site with a smaller response body.

I'm not very familiar with the library you're using but you might want to try manually setting the User-Agent header.

For example:

User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...