Skip to content
WJunction - Webmaster Forum

Parse $html using html dom

Status
Not open for further replies.
I have all of my data going into my $html variable.
What i am struggling with is parsing the data, can anyone help me?
I have searched online for this for a good few days but everything i try doesn't work.

I am grabbing the RSS feed by this method:

PHP:
//RSS Read
$rss = simplexml_load_file('http://iptorrents.com/torrents/rss?l7;l3;l4;u=650269;tp=0186466a09ea2b73868765a1b238e42e');
echo '<h1>'. $rss->channel->title . '</h1>';
foreach ($rss->channel->item as $item) {
    echo '<h2><a href="'. $item->link .'">' . $item->title . "</a></h2>";
    $x=explode('/',$item->link);
    $id=$x[1];
    
}

Getting the HTML from pages using this method:


PHP:
$html = file_get_html($item->link);

Just can't seem to figure out how to parse the $ for the information inside of the links.

I have tried doing this but doesn't work:

PHP:
foreach($html->find('.imdb-photo') as $tr) {
        
        echo $tr;
    }


EDIT:

I now have the page being grabbed and outputting on to the html page where my links are.
i used this code:

PHP:
// Start a cURL resource
$ch = curl_init();
// Set options for the cURL
curl_setopt($ch, CURLOPT_URL, 'http://iptorrents.com/details.php?id=1003336'); // target
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // provide a user-agent
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
        curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow any redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the result
// Execute the cURL fetch
$result = curl_exec($ch);
// Close the resource
curl_close($ch);
// Output the results
echo $result;

Now i need to try figure out how to make it scrape the links on my index.php page that are being scraped from http://iptorrents.com/torrents
 
Last edited:
Status
Not open for further replies.

About the author

B
Senior Member · Joined
1,286
Messages
211
Reactions
63
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom