diff --git a/getdata.php b/getdata.php index 738ea37..c2a9498 100644 --- a/getdata.php +++ b/getdata.php @@ -4,52 +4,43 @@ $password="vpsad24068"; $hostname = "localhost"; //connection string with database $dbhandle = mysqli_connect($hostname, $username, $password) -or die("Unable to connect to MySQL"); -echo ""; + or die("Unable to connect to MySQL"); + // connect with database $selected = mysqli_select_db($dbhandle, "wptest") -or die("Could not select examples"); -//$email = 'francesco.finazzi@unibg.it'; + or die("Could not select examples"); + $queryurl = "SELECT url,email FROM wp_autori2url"; $result = mysqli_query($dbhandle,$queryurl); -//$url = 'http://export.arxiv.org/api/query?search_query=au:Finazzi_F'; + $url = ''; while($row = mysqli_fetch_object($result)){ $url = $row->url; $email = $row->email; -$xml = file_get_contents($url); -$newxml = str_replace('arxiv:','arxiv_',$xml); -//$xml = simplexml_load_file($url); //retrieve URL and parse XML content -//echo $xml->getName(); // output name of root element -$xmlparse = simplexml_load_string($newxml); -//$xmlparse = simplexml_load_string(html_entity_decode($xml), 'SimpleXMLElement', LIBXML_NOCDATA); + $xml = file_get_contents($url); + $newxml = str_replace('arxiv:','arxiv_',$xml); + //$xml = simplexml_load_file($url); //retrieve URL and parse XML content + //echo $xml->getName(); // output name of root element + $xmlparse = simplexml_load_string($newxml); + //$xmlparse = simplexml_load_string(html_entity_decode($xml), 'SimpleXMLElement', LIBXML_NOCDATA); -// $xml = file_get_contents('http://export.arxiv.org/api/query?search_query=au:Finazzi_F'); -//$articoli = array('http://export.arxiv.org/api/query?search_query=au:Finazzi_F'); -//foreach( $articoli as $articolo ) { -//$xml = simplexml_load_file($articoli); + $queryTrun = " TRUNCATE TABLE wp_rawdata "; + mysqli_query($dbhandle,$queryTrun); -$queryTrun = " TRUNCATE TABLE wp_rawdata "; -mysqli_query($dbhandle,$queryTrun); + foreach($xmlparse->entry as $item) + { + $date_format = "j-n-Y"; // 7-7-2008 -foreach($xmlparse->entry as $item) -{ -$date_format = "j-n-Y"; // 7-7-2008 - -// foreach($item->xpath('link') as $link) -// { -// echo $link->xpath('title'); -// } - - echo '

'; - echo $item->published; - echo '
'.$item->title.'
'; - echo '

' . $item->summary . '





'; -$autori = ''; -foreach($item->author as $autore){ - $autori = $autori.$autore->name. ', '; + echo '

'; + echo $item->published; + echo '
'.$item->title.'
'; + echo '

' . $item->summary . '





'; + $autori = ''; + foreach($item->author as $autore){ + $autori = $autori.$autore->name. ', '; } + echo $autori .'
'; $categorie = ''; @@ -57,21 +48,13 @@ foreach($item->category as $categoria){ $categorie = $categorie.$categoria['term']. ', '; } -echo $categorie .'
'; +//echo $categorie .'
'; //echo '
' . $item->xpath('link')->title . '





'; //echo '
' . $item->content . '



'; - echo '

'; - -$prova = mysqli_query($dbhandle,"SELECT * FROM wp_iscritti"); -//$item->published = '2018-07-04'; -//$newdate = date("Y-m-d",strtotime($item->published)); +// echo '

'; $item->published = date("Y-m-d",strtotime($item->published)); -//$item->published = string(date($item->published)); -//echo $prova; -//$query = "INSERT INTO wp_rawdata ( email, doi, published, title, summary, authors, ajournal, categories); - $query = "INSERT INTO wp_rawdata ( email, doi, published, title, summary, authors, ajournal, categories) VALUES ( @@ -87,18 +70,6 @@ VALUES ( echo $query; mysqli_query($dbhandle,$query); -// mysqli_query($dbhandle,"INSERT INTO wp_rawdata (idx, doi, email, published, title, summary, authors, ajournal, categories) -// VALUES ( -// '', -// '".mysqli_real_escape_string($dbhandle,$item->id)."', -// '".mysqli_real_escape_string($dbhandle,$email)."', -// '".mysqli_real_escape_string($dbhandle,$item->published)."', -// '".mysqli_real_escape_string($dbhandle,$item->title)."', -// '".mysqli_real_escape_string($dbhandle,$item->summary)."', -// '".mysqli_real_escape_string($dbhandle,$autori)."', -// '".mysqli_real_escape_string($dbhandle,$item->arxiv_journal_ref)."', -// '".mysqli_real_escape_string($dbhandle,$categorie)."', -// "); } //inserimento nuovi articoli $query = "INSERT INTO wp_articoli (doi, published, title, summary, authors, ajournal, categories)