Extracting text from a remote web page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
terrym
Forum Newbie
Posts: 5
Joined: Wed May 29, 2002 3:51 pm
Location: United Kingdom

Extracting text from a remote web page

Post by terrym »

Hi.
I have a requirement to extract certain text from a remote Web Page.
I want to extract Meta Keywords, Meta Description, text between H2 tags, and some general Body text.
I have tried XML HTTP Request object, but I cannot get the example (from jibbering.com) to work.
Would this be difficult, or does someone know an easy (?) way to do this?
User avatar
enygma
Site Admin
Posts: 175
Joined: Fri Apr 19, 2002 8:29 am
Location: Dallas, Tx

Post by enygma »

grab the page ( with a file() maybe?) and then just regexp out what you need....
User avatar
riley
Forum Commoner
Posts: 45
Joined: Thu May 02, 2002 6:31 pm

Post by riley »

I get the latest incentives directly from chevrolet with this code.
[syntax=php]<?php
$site = "http://www.chevrolet.com/cur_offers/pri ... h_east.htm";
$open = fopen($site, "r");
$search = fread($open, 50000);
fclose($open);
$search = ereg("SOUTH EAST(.*)", $search, $content);
$content[1] = str_replace(" ", " ", $content[1]);
$content[1] = str_replace("href=", "", $content[1]);
echo $content[1];

?>[/syntax]
Post Reply