Support » Plugins and Hacks » Hacks » Get DD element value from other website?

Get DD element value from other website?

  • I am looking for the best and server friendly method of geting DD element value echo’ed on my WordPress site, inside div.

    I need to scrap 9.th <dd>value</dd> from other website, and I’ve had no success. This is the jQuery code I found online, but it doesn’t work.

    $(document).ready(function() {
      $.get("http://otherwebsite.com", function(data) {
        var resp = $(data);
        $("dd:eq(9)", resp).appendTo("body"); // dd:eq(9) for selecting 9.th DD value
      setTimeout(function() {
      }, 10000);
Viewing 2 replies - 1 through 2 (of 2 total)
  • Drew Jaynes


    Docs Czar

    You’re probably better off retrieving the body using the HTTP API then scraping the result. I guess it largely depends on whether you need the data client-side (as with js) and whether you need to prepare it for display on the other side (easier server-side).

    I already wrote PHP code, as it turns out Javascript can’y do that. At all 🙂
    Just in case anyone is looking –

    $data = file_get_contents("http://website.com");
    preg_match("#<dt>Seeders:<\/dt>\s*<dd>(.*)<\/dd>#iU", $data, $match1);
    preg_match("#<dt>Leechers:<\/dt>\s*<dd>(.*)<\/dd>#iU", $data, $match2);
    echo $match1[1]; //seeders
    echo $match2[1]; //leechers

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get DD element value from other website?’ is closed to new replies.
Skip to toolbar