Visualizzazione dei risultati da 1 a 2 su 2

Discussione: web Grab [PROBLEMA]

  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2011
    Messaggi
    5

    web Grab [PROBLEMA]

    ciao ragazzi, ho un problema ho creato uno script per grabbare delle informazioni mirate da siti web...ma non riesco a inserirli nel database!!
    ecco lo script

    Parse.php
    <?php
    class ParseSite{

    var $DataFromSite = '';

    function __construct($url){
    $this->url = $url;
    $this->DataFromSite = $this->grab_page();
    }

    private function grab_page(){
    $this->CurlOP = array(
    CURLOPT_RETURNTRANSFER => true, // return web page
    CURLOPT_HEADER => false, // don't return headers
    CURLOPT_FOLLOWLOCATION => true, // follow redirects
    CURLOPT_ENCODING => "", // handle all encodings
    CURLOPT_USERAGENT => "LWS V1.0", // who am i
    CURLOPT_AUTOREFERER => true, // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
    CURLOPT_TIMEOUT => 120, // timeout on response
    CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
    CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
    CURLOPT_SSL_VERIFYPEER => false, //
    );
    $this->ch = curl_init($this->url);
    curl_setopt_array($this->ch,$this->CurlOP);
    $this->Data = curl_exec($this->ch);
    curl_close($this->ch);
    return $this->Data;
    }

    function get_doctype(){
    $h1tags = preg_match('/<!DOCTYPE (\w.*)dtd">/is',$this->DataFromSite,$patterns);
    $res = array();
    array_push($res,$patterns[0]);
    array_push($res,count($patterns[0]));
    return $res;
    }

    // retrieve page title
    function get_doc_title(){
    $h1tags = preg_match('/<title> ?.* <\/title>/isx',$this->DataFromSite,$patterns);
    $res = array();
    array_push($res,$patterns[0]);
    array_push($res,count($patterns[0]));
    return $res;
    }

    // retrieve keywords
    function get_keywords(){
    $h1tags = preg_match('/(<meta name="keywords" content="(.*)" \/>)/i',$this->DataFromSite,$patterns);
    $res = array();
    array_push($res,$patterns[2]);
    array_push($res,count($patterns[2]));
    return $res;
    }
    }

    ?>

    index.php

    <?php

    include 'parse.php';
    $Parse = new ParseSite("http://www.google.com");
    echo "<pre>";
    var_dump(
    $Parse->get_doctype(),
    $Parse->get_doc_title(),
    $Parse->get_keywords(),
    $Parse->get_link_rel(),
    $Parse->get_domain_name_only()
    );
    echo "</pre>";




    ?>

  2. #2
    embè? nello script postato mica provi ad inserirli in un database
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.