Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...