4
Contributors
10
Replies
14
Views
6 Years
Discussion Span
Last Post by matricol
0

Well, assuming you really want JS, you can just do document.getElementsByTagName('title') and ...('meta'). If you actually get this info on another server, without running any code from that page, what I would find more logical, you could use an XML parser or just some regular expression to get the info.

0

actually i am new to coding!
so if you give me a example or refer any article that will better for me.
Thankyou

0

Thanks twiss,
suppose if i want to extract www.google.com "Title" then what changes needed for below code?

function getTitle($Url){
	$str = file_get_contents($Url);
	if(strlen($str)>0){
		preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
		return $title[1];
	}
}
//Example:
echo getTitle("http://localhost/");
0

Hello,
here i am showing you a code that extract a page TITLE, DESCRIPTION perfectly.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>amar titkle</title>
 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="description" content="shob kisur bornona" />
<meta name="keywords" content="eta ki, googl , bd, in" />
<style type="text/css">
#Box{border:1px solid #000044;text-align:center;background-color : #fff;} 
#green {color:green }
</style>
</head>
<body><h1>Niche Dekhun</h1><br />
<div id="Box">
<script type="text/javascript">
//<![CDATA[
var a = (document.title);
var b = (document.location.href);
var c = document.getElementsByTagName('meta');
var description;
for (var x = 0, y = c.length; x < y; x++) {
    if (c[x].name.toLowerCase() == "description") {
        description = c[x];
    }
}
document.write('<a href="' + b + '">' + a + '<\/a><br />' + description.content + '<br />');
document.write('<span id="green">' + b + '<\/span>');
//]]>
</script>
</div>
</body>
</html>

What then if i want to extract TITLE, DESCRIPTION of a URL by this above code in my website? What types of changes i need to do in this code?
Hoping a great response!
Thankyou

0

Merging this with your other thread for the same question.

Please do not scatter the discussion over multiple threads.

Edited by Ezzaral: n/a

0

this is a new code i find over net, so it can'?@Ezzaral

0

It is still basically the same question. Spreading that across many threads just creates a cluttered mess and people may waste their time typing duplicate suggestions that have already been given in another thread.

0

only javascript can do that document.title and document.getElementsByTagName('meta') will do the job .. load this code into the 2 var needed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.