简体   繁体   中英

i want to save scraped content directly to database please correct this

i want to save scraped content directly to database please correct this

i only want to save in text format, without password and only code others like title expires (none) all remain the same

<?php
include('simple_html_dom.php');

$code = file_get_html('http://domain.com/')->plaintext; 

$con=mysqli_connect("<dbhost>","<dbuser>","<dbpass>","<dbname>");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$dati = date('Y-m-d H:i:s');

$pid = pid + 1; // 

help with this also pid increase with every post

mysqli_query($con,"INSERT INTO `paste` (`pid`, `poster`, `posted`, `code`, `parent_pid`, `format`, `codefmt`, `codecss`, `expires`, `expiry_flag`, `password`)
VALUES  ($pid, 'Untitled', $dati, $code, 0, 'text', '<div class="text"><ol><li class="li1"><div class="de1">' . $code . '</div></li>\n</ol></div>', '/**\n * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann\n * (http://qbnz.com/highlighter/ and http://geshi.org/)\n */\n.text .de1, .text .de2 {font: normal normal 12px monospace; margin:0; padding:0; background:none; vertical-align:top;}\n.text  {font-family:monospace;}\n.text .imp {font-weight: bold; color: red;}\n.text li, .text .li1 {background: #ffffff;}\n.text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}\n.text .li2 {background: #f4f4f4;}\n.text span.xtra { display:block; }\n', NULL, 'f', 'EMPTY')");
?>
/*********** Load In Dom *********/
$html = new DOMDocument;
$html->loadHTML($yourTargetHTML);
$xPath = new DOMXPath($html);
/*********** Load In Dom *********/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM