Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $hostname = "localhost";
- $username = "trending_alex";
- $pass = "TariqAlex95";
- $db_name = "trending_alex";
- $conn_string = "mysql:host=$hostname;dbname=$db_name";
- $dbh = new PDO($conn_string, $username, $pass);
- $sql = "SELECT * from news";
- $pdo_i = $dbh->query($sql);
- $arr = $pdo_i->fetchALL(PDO::FETCH_ASSOC);
- $file = "http://seekingalpha.com/feed.xml";
- $xml = simplexml_load_file($file) or die ("Can't read $file!");
- foreach ($xml->channel->item as $it) {
- // if ($it->category=="AKS" || $it->category=="GLD" || $it->category=="AAPL" || $it->category=="FB" || $it->category=="TWLO" || $it->category=="NVDA" || $it->category=="NVDA" || $it->category=="X" )
- // echo
- // "<a href='".$it->link."'>".
- // $it->title." ".$it->pubDate ."<br /></a>";
- $trig=0;
- foreach($arr as $news) {
- if ($news['source']=="seekingalpha" && $news["newsid"]==$it->guid)
- {
- $trig=1;
- break;
- }
- }
- if ($trig==0)
- {
- $sql1 = "INSERT INTO news(title) ";
- $sql1 .= "VALUES ('".$it->title."')";
- $dbh->exec($sql1) or die($dbh->errorinfo());
- //var_dump($sql1);
- }
- }
- $dbh = null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement