English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How can I find the address of all images(.gif,.jpg,.jpeg,.png) in a web page? I want to add the address(URL) of all the images that are in a webpage, to my db.

2006-08-14 19:07:22 · 7 answers · asked by QuestionAnswer 2 in Computers & Internet Programming & Design

7 answers

1. Load file into one big string.
2. Use strstr to search

2006-08-14 19:16:06 · answer #1 · answered by Ken H 4 · 0 1

Not a trivial task...

First, get the entire page into a single string varilable using file_get_contents() or cURL.

Second, isolate all instances of tag. You could use regular expressions or DOM functions for that.

Third, isolate the content of the src attribute contained within each tag.

Fourth, determine if the src attribute contains a relative or absolute reference using parse_url(). If the reference is relative, make it into an absolute one by combining it with parts of the page's URL.

Finally, record the result into the database...

2006-08-16 06:53:14 · answer #2 · answered by NC 7 · 1 0

Go on "www.dummies.com" and search for PHP 5 for dummies.
That's a very good book and there you'll find your answer.

2006-08-14 20:19:38 · answer #3 · answered by cotelp2006 2 · 0 0

plz be specific with your question. or else you can download php manual from php.net site. everything about php is available in the manual.

2006-08-14 19:25:03 · answer #4 · answered by LemonPro 5 · 0 0

$lines = file("http://www.website.com");
$html = join("",$lines);


// remove all line breaks
$html = str_replace("\n","",$html);
// and put in a new line break behind every anchor tag
$html = str_replace("","\n",$html);
// split the string into single lines
$lines = split("\n",$html);

// $lines now is an array of lines and each line ends with an anchor tag
// for every anchor tag, we now have an entry in $lines
for($i=0;$i {
// delete everything in front of the anchor tag
$lines[$i] = eregi_replace(".* // now every line just consists of something like ...
// we extract the link within the href attribut ...
eregi("href=[\"']{0,1}([^\"'> ]*)",$lines[$i],$regs);
// and put it into the $lines array
$lines[$i] = $regs[1];
}

2006-08-14 19:16:16 · answer #5 · answered by ramirovarandas 1 · 2 0

Well for you egold users out ther I wrote this to just return the balance ONLY
If anyone knows a better way to write this lemme know as im a novice

function _GetBalance($from, $frompass) {
$defined_vars = get_defined_vars();

$_url = 'https://www.e-gold.com/acct/balance.asp';

$_url_p = "AccountID=" . $from . "&PassPhrase=" . $frompass ."";
$ch = curl_init();

curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$_url_p);
curl_setopt($ch, CURLOPT_URL,$_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$content = curl_exec ($ch);

curl_close ($ch);
$content=strtolower($content);
$content=strstr($content,"");
$content=strip_tags($content);
$content=strrev($content);
$content=strstr($content,"eseht :eton");
$content=str_replace("eseht :eton","",$content);
$content=ltrim($content);
$content=rtrim($content);
$content=substr($content,0,11);
$content=strrev($content);
$content=ltrim($content);

return $content;

}

2006-08-14 19:29:37 · answer #6 · answered by kartoos5050 2 · 0 2

technique a million if(mysql_query("INSERT INTO ....")){ // What to do if question succeeds? } else{ die(mysql_error()); } ---------------- technique 2 mysql_query("INSERT INTO ...") or die(mysql_error());

2016-12-17 11:07:09 · answer #7 · answered by ? 4 · 0 0

fedest.com, questions and answers