我想将抓取的内容直接保存到数据库中请更正
我只想以文本格式保存,没有密码,只有代码 其他如标题到期(无)都保持不变
<?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; //
每次发布帮助 pid增加
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')");
?>
答案 0 :(得分:0)
/*********** Load In Dom *********/
$html = new DOMDocument;
$html->loadHTML($yourTargetHTML);
$xPath = new DOMXPath($html);
/*********** Load In Dom *********/