Jump to content

souvikdgp

Members
  • Posts

    3
  • Joined

  • Last visited

souvikdgp's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. souvikdgp.heliohost.org/secure-json2/fetch-site-data-ajax.php?url=webstatzone.com You can see nothing is reported here. A blank page is coming. Let me know if you need any further help. <?php ini_set('display_errors',1); error_reporting(E_ALL); //header('Content-type: application/json; charset=utf-8'); require('urlResolver/URLResolver.php'); $curlUserAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)'; function get_curl_content( $url ) { $resolver = new URLResolver(); # Identify your crawler (otherwise the default will be used) $resolver->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)'); # Designate a temporary file that will store cookies during the session. # Some web sites test the browser for cookie support, so this enhances results. $resolver->setCookieJar('/tmp/url_resolver.cookies'); # resolveURL() returns an object that allows for additional information. $url_result = $resolver->resolveURL($url); $url = $url_result->getURL(); $header = array(); $header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'; $header[] = 'Cache-Control: max-age=0'; $header[] = 'Connection: keep-alive'; $header[] = 'Keep-Alive: 300'; $header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7'; $header[] = 'Accept-Language: en-us,en;q=0.5'; $header[] = 'Pragma: '; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)'); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $result = curl_exec($ch); curl_close ($ch); $returnData = array(); $returnData['content'] = $result; return $returnData; } $url = $_GET["url"]; $ip_addr = $_SERVER['REMOTE_ADDR']; function makeValidJson($description){ $description = str_replace("'",''',$description); $description = preg_replace('/[\x09]/', ' ', $description); $description = preg_replace('/[\x0D]/', ' ', $description); $description = (addslashes($description)); $description = str_replace("\r\n", "", $description); $description = str_replace("\n", "", $description); return utf8_encode($description); } include 'web-header-meta.php'; $dummyUrl = "http://" . $url; $returnString = "{\"data\" : {"; $id = 0; $returnString .= web_header_meta($dummyUrl,$url, $id); $returnString .= "}}"; echo $returnString; ?> and here's the web_header_meta function: function web_header_meta($domain, $origUrl, $id){ //$url = "http://" . $domain; $url = $domain; $data = get_curl_content($url); $data = $data["content"]; if(($data == null || strlen($data) == 0) && strrpos($url, "www.") === false){ $url = "http://www." . $domain; $data = get_web_page($url); $data = $data["content"]; } //parsing begins here: $doc = new DOMDocument(); $doc->loadHTML($data); $metas = $doc->getElementsByTagName('meta'); $returnMeta = '"meta":['; if($metas->length > 0){ $nodes = $doc->getElementsByTagName('title'); //get and display what you need: $title = $nodes->item(0)->nodeValue; for ($i = 0; $i < $metas->length; $i++) { $meta = $metas->item($i); if($meta->getAttribute('name') && strlen($meta->getAttribute('name')) > 0){ $returnMeta .= '{"'. makeValidJson($meta->getAttribute('name')) . '":"' . makeValidJson($meta->getAttribute('content')) . '"},'; } else if($meta->getAttribute('http-equiv') && strlen($meta->getAttribute('http-equiv')) > 0){ $returnMeta .= '{"'. makeValidJson($meta->getAttribute('http-equiv')) . '":"' . makeValidJson($meta->getAttribute('content')) . '"},'; } } $returnMeta .= '{"Title":"' . makeValidJson($title) . '"}'; } $returnMeta .= '],'; return $returnMeta; } Hi, some cookie was creating issue. I have debug and fixed it. This was not the case earlier though. Anyway thanks for your support. You were very much helpful in resolving the issue.
  2. No.There's no log file. i tired to add error reporting by using ini_set('display_errors',1); error_reporting(E_ALL); in my code. But even then nothing is logging. It was working fine till yesterday. Since today morning I am watching this problem.
  3. Hi, I have a page which takes a domain name as input and then tells user about the mata tags of that domain home page. To do I used curl and PHP. It was working fine until today. Since today morning it returning blank page. no error nothing. Can someone please help? My website is hosted in Johnny server.
×
×
  • Create New...