Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Have Unity access a web address and pull data from a specific part of it - Can I get some guidance?

Discussion in 'Scripting' started by SuperZac, Jul 6, 2014.

  1. SuperZac

    SuperZac

    Joined:
    Mar 1, 2013
    Posts:
    20
    Hello Unity forums, I am here to ask for some help, or at least a push in the right direction. I want to have Unity access a web address and return the contents of a specific part of it. Completely specifically, I want unity to access http://www.urbandictionary.com/random.php and return the contents of the first result.
    Is there a way (possibly using the WWW and WWWForm classes?) to access the webpage and point it to a specific part of the html?
    Thank you for any help, I usually figure this stuff out on my own but I'm not very good with the terminology relevant to this problem.
    Have an excellent day!
     
  2. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    No, not really. You can use WWW to grab the contents of the whole page, but then you'll have to use some sort of text processing (e.g. regular expressions) to extract the results that you want.

    FYI: This is called content scraping, and some websites explicitly prohibit it.
     
  3. SuperZac

    SuperZac

    Joined:
    Mar 1, 2013
    Posts:
    20
    Okay, thanks. Taking a closer look, it appears that Urban Dictionary actually has a form that you can fill out regarding the API they are developing, and questions being asked involve how many calls the app will make to the site, etc. So if I made a game accessing their website, it would put a lot of traffic on them, which almost definitely wouldn't be cool.

    Thanks again for your response, yet another idea I'll be throwing in the trash...
     
  4. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Not necessarily. There are alternatives like Wiktionary. Not sure if they have a random word function, but everything else is there, including a web API. It should have almost everything you'll need.

    Good luck :)