|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
This is two simple functions that I always use for content grabbing from another website. Easy to use, with sample.
Here are the two main functions:
| <?php
// get content of URL into string
function getContentOfURL($url){
$file = fopen($url, "r");
if($file){
while (!feof ($file)) {
$line .= fread ($file, 1024*50);
}
return $line;
}
return false;
}
// get value of text inbetween tags
function getContentByTag($tag1,$tag2,$string) {
if (eregi("$tag1(.*)$tag2", $string, $out)) {
$outdata = $out[1];
}
return $outdata;
}
?> | |
Here are the examples to get value of <title></title> tags from Google.com:
| <?php
$string = getContentOfURL('http://google.com');
$title = getContentByTag('<title>','</title>',$string);
echo $title;
?> | | |
|
| How to preset a text string in a textarea input field Categories : HTML, HTML and PHP, PHP, Beginner Guides | | | Newbie Notes #1 - Making a form return to itself Categories : PHP, Beginner Guides, HTML and PHP | | | mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases | | | a PHP Function to Get only the filename (remove the extension) using regular expressions. Categories : PHP, Regexps, Beginner Guides | | | php table decoder used to convert an html table to individual tokens
through regular expressions Categories : PHP, Regexps, HTML and PHP | | | Form input return conformance Categories : HTML and PHP, PHP, Regexps | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | Simple POST and GET example Categories : PHP, Beginner Guides, Form Processing, HTML and PHP | | | Newbie Notes #9 - Hyperlinking a post Categories : PHP, Java Script, HTML and PHP, Beginner Guides | | | Parse a HTML-document for a certain tag and display its content and attributes. Categories : HTML and PHP, PHP, Tag Extractors | | | How to use regular expressions to get the list of links from an HTML page Categories : PHP, Regexps, HTML, HTML and PHP | | | Using PHP im HTML image tags Categories : PHP, HTML and PHP, Graphics, Beginner Guides | | | Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance. Categories : HTML, PHP, HTML and PHP, Beginner Guides | | | How to Create a Shoutbox Using PHP & MySQL Categories : PHP, MySQL, Web Applications, Beginner Guides, HTML and PHP | | | Kewl Date Example Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides | |
|
|
|