93 lines
3.0 KiB
PHP
93 lines
3.0 KiB
PHP
<?php
|
|
$username="root";
|
|
$password="vpsad24068";
|
|
$hostname = "localhost";
|
|
//connection string with database
|
|
$dbhandle = mysqli_connect($hostname, $username, $password)
|
|
or die("Unable to connect to MySQL");
|
|
echo "";
|
|
// connessione al database
|
|
$selected = mysqli_select_db($dbhandle, "wptest")
|
|
or die("Could not select examples");
|
|
//$email = 'francesco.finazzi@unibg.it';
|
|
|
|
$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('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);
|
|
|
|
foreach($xmlparse->entry as $item)
|
|
{
|
|
$date_format = "j-n-Y"; // 7-7-2008
|
|
|
|
// foreach($item->xpath('link') as $link)
|
|
// {
|
|
// echo $link->xpath('title');
|
|
// }
|
|
|
|
echo '<style type="text/css">.style1 { direction: rtl;</style><p class="style1">';
|
|
echo $item->published;
|
|
echo '<br><a href="'.$item->id.'" target="_blank">'.$item->title.'</a><br>';
|
|
echo '<div>' . $item->summary . '</div><br><br><br><hr><br>';
|
|
$autori = '';
|
|
foreach($item->author as $autore){
|
|
$autori = $autori.$autore->name. ', ';
|
|
}
|
|
echo $autori .'<br>';
|
|
|
|
$categorie = '';
|
|
foreach($item->category as $categoria){
|
|
$categorie = $categorie.$categoria['term']. ', ';
|
|
}
|
|
|
|
echo $categorie .'<br>';
|
|
//echo '<div>' . $item->xpath('link')->title . '</div><br><br><br><hr><br>';
|
|
//echo '<div>' . $item->content . '</div><br><br><br>';
|
|
echo '</p>';
|
|
|
|
$prova = mysqli_query($dbhandle,"SELECT * FROM wp_iscritti");
|
|
$item->published = '2018-07-04';
|
|
//echo $prova;
|
|
$query = "INSERT INTO wp_rawdata ( email, doi, published, title, summary, authors, ajournal, categories)
|
|
VALUES (
|
|
'$item->id',
|
|
'$email',
|
|
'$item->published',
|
|
'$item->title',
|
|
'$item->summary',
|
|
'$autori',
|
|
'$item->arxiv_journal_ref',
|
|
'$categorie'
|
|
)";
|
|
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)."',
|
|
// ");
|
|
}
|
|
}
|
|
// }
|
|
?>
|