Search Unity

Problem with WWW Class when you get the code of a webpage

Discussion in 'Editor & General Support' started by AngelFeria, Apr 15, 2018.

  1. AngelFeria

    AngelFeria

    Joined:
    Mar 20, 2018
    Posts:
    3
    Hello eveyone, I need help, I am using the class WWW for get a code source of a webpage.
    The problem is that the code that I get is short, and I need all code of all webpage...

    In the console only I can see short code and If I put the text to a text gameobject Unity says that it´s very big to show me.

    Example:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. using UnityEngine.UI;
    6.  
    7. public class Web : MonoBehaviour {
    8.  
    9.     public Text responseText;
    10.  
    11.     public void Request(){
    12.  
    13.          WWW request = new WWW("http://youtube.com");
    14.          StartCoroutine(OnResponse(request));
    15.  
    16.  
    17.     }//Request
    18.  
    19.    
    20.     private IEnumerator OnResponse(WWW req){
    21.  
    22.         yield return new WaitForSeconds ( 3 );
    23.  
    24.         Debug.Log(req.text);
    25.    
    26.    
    27.     }//DescargarContenido
    28.  
    29.  
    30. }//Web
    31.  
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    Click on the line in cosole. It shows you only the beginning, but when clicking it should show you all in the bottom part of console (below the split).
    So this isn't the problem with WWW, it's a problem with showing the downloaded text.
     
  3. AngelFeria

    AngelFeria

    Joined:
    Mar 20, 2018
    Posts:
    3
    Hello Aurismas-Cernius Thanks a lot for your reply. I can´t see the final of the code yet (</body></html> for example en HTML)



    My problem is the next, I need to get a webpage code (all code), and later find a line of text with IndexOf, etc... but this last not is important now...

    I only know that this is possible with the class WWW

    But, when I had the code into a variable and I tried IndexOf in the final of the code <html> for example, not works, I thought that is a error of IndexOf, so, I tried to show it in the console...

    With debug.log, i can show a line, i can CLICK and show more... but... i can see all code.

    The code CUT more or less 6000 characters, I don´t know Why...
    Sometimes I thought that the variable STRING can´t save a lot of words :(

    I don´t know how i can get all code of my web yet


    Thanks for all!
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    Try printing WWW.bytes property to file and then check it's contents. It's something strange here...
     
  5. AngelFeria

    AngelFeria

    Joined:
    Mar 20, 2018
    Posts:
    3