TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   scraping a webpage for text (http://www.talkphp.com/absolute-beginners/3758-scraping-webpage-text.html)

sarmenhb 12-12-2008 12:42 AM

scraping a webpage for text
 
hello,

i'm trying to make an app that when a user enters a domains name the file_get_contents will scrape only the visible text on the page and display to the user

this is what i've got so far

Code:


<?php
$data = file_get_contents('http://www.gothostin.com/sarmenhb');
$regex = '/[a-zA-z]/';
preg_match($regex,$data,$match);
var_dump($match);
echo $match[1];
?>

but i keep getting something like array{0} or something

what am i doing wrong?

thanks

Wildhoney 12-12-2008 02:49 AM

Only the visible text as opposed to...

martins256 12-12-2008 05:34 AM

Why can't you use strip_tags() ?
<?php
echo strip_tags(file_get_contents('http://www.gothostin.com/sarmenhb'));
?>


All times are GMT. The time now is 09:43 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0