Can anyone advice me on this please. We are starting a website. This will be for rating websites similar to www.xomreviews.com We need a code to automatically generate TItle, description and tags(keywords) of a site. When a website's URL is submitted in to our database, it should automatically display the title, description and tags(keywords of that site.) similar to www.xomreviews.com You will be rewarded for this. Thank you
Okay, here is a quick function to get you started. To use it, copy the script below into your page. Then, just call the function like this: getURLMetaInfo('http://www.sitepoint.com/') It will return the information, if it found it. Otherwise, it might return some gibberish. You can clean it up to perform how you want. In addition to parsing the meta data, this script is also doing some useragent and referer spoofing here in case the pages are protected. Do I get a reward too? -------------------- SCRIPT BELOW --------------------------- <cfscript> function getTag(_string,_start,_end) { _startPos = findNocase(_start,_string) + len(_start); _endPos = findNoCase(_end,_string,_startPos) - _startPos; return mid(_string, _startPos, _endPos); } </cfscript> <cffunction name="getURLMetaInfo" access="public" returntype="struct"> <cfargument name="src" required="true"> <cfset var resultObj = structNew()> <!--- Retrieve the URL ---> <cfhttp url="#arguments.src#" method="GET" useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2" result="objHttp"> <!--- Spoof Referer just in case ---> <cfhttpparam type="CGI" name="http_referer" value="#arguments.src#" encoded="false" /> </cfhttp> <cfset _o = objHTTP.filecontent> <!--- Get the title ---> <cfset resultObj.title = getTag(_o,"<title>","</title>")> <!--- Get the meta description ---> <cfset resultObj.description = getTag(_o,'<meta name="keywords" content="','"')> <!--- Get the meta keywords ---> <cfset resultObj.keywords = getTag(_o,'<meta name="description" content="','"')> <cfreturn resultObj> </cffunction>