chapter_page php,chapter.php

<?php require_once('data/config.php'); ?><?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}

$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

$insertSQL = sprintf("INSERT INTO `comment` (name, `date`, wzid, `comment`) VALUES (%s, %s, %s, %s)",

GetSQLValueString($_POST['pl_name'], "text"),

GetSQLValueString($_POST['pl_date'], "date"),

GetSQLValueString($_POST['pl_wzid'], "int"),

GetSQLValueString($_POST['pl_comment'], "text"));

mysql_select_db($database_config, $config);

$Result1 = mysql_query($insertSQL, $config) or die(mysql_error());

$insertGoTo = "chapter.php";

if (isset($_SERVER['QUERY_STRING'])) {

$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

$insertGoTo .= $_SERVER['QUERY_STRING'];

}

header(sprintf("Location: %s", $insertGoTo));

}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_chapter = 1;

$pageNum_chapter = 0;

if (isset($_GET['pageNum_chapter'])) {

$pageNum_chapter = $_GET['pageNum_chapter'];

}

$startRow_chapter = $pageNum_chapter * $maxRows_chapter;

$colname_chapter = "-1";

if (isset($_GET['id'])) {

$colname_chapter = $_GET['id'];

}

mysql_select_db($database_config, $config);

$query_chapter = sprintf("SELECT * FROM sls_wz WHERE id = %s", GetSQLValueString($colname_chapter, "int"));

$query_limit_chapter = sprintf("%s LIMIT %d, %d", $query_chapter, $startRow_chapter, $maxRows_chapter);

$chapter = mysql_query($query_limit_chapter, $config) or die(mysql_error());

$row_chapter = mysql_fetch_assoc($chapter);

if (isset($_GET['totalRows_chapter'])) {

$totalRows_chapter = $_GET['totalRows_chapter'];

} else {

$all_chapter = mysql_query($query_chapter);

$totalRows_chapter = mysql_num_rows($all_chapter);

}

$totalPages_chapter = ceil($totalRows_chapter/$maxRows_chapter)-1;

mysql_select_db($database_config, $config);

$query_system = "SELECT * FROM sls_system";

$system = mysql_query($query_system, $config) or die(mysql_error());

$row_system = mysql_fetch_assoc($system);

$totalRows_system = mysql_num_rows($system);

mysql_select_db($database_config, $config);

$query_new_mood = "SELECT * FROM sls_wz ORDER BY id DESC";

$new_mood = mysql_query($query_new_mood, $config) or die(mysql_error());

$row_new_mood = mysql_fetch_assoc($new_mood);

$totalRows_new_mood = mysql_num_rows($new_mood);

mysql_select_db($database_config, $config);

$query_new_chapter = "SELECT * FROM sls_wz ORDER BY id DESC";

$new_chapter = mysql_query($query_new_chapter, $config) or die(mysql_error());

$row_new_chapter = mysql_fetch_assoc($new_chapter);

$totalRows_new_chapter = mysql_num_rows($new_chapter);

$colname_pl = "-1";

if (isset($_GET['wzid'])) {

$colname_pl = $_GET['wzid'];

}

mysql_select_db($database_config, $config);

$wzid =$row_chapter['id'];//是你当前文章的编号

$query_pl = sprintf("SELECT * FROM `comment` WHERE wzid = $wzid ORDER BY id DESC", GetSQLValueString($colname_pl, "int"));

$pl = mysql_query($query_pl, $config) or die(mysql_error());

$row_pl = mysql_fetch_assoc($pl);

$totalRows_pl = mysql_num_rows($pl);

$queryString_chapter = "";

if (!empty($_SERVER['QUERY_STRING'])) {

$params = explode("&", $_SERVER['QUERY_STRING']);

$newParams = array();

foreach ($params as $param) {

if (stristr($param, "pageNum_chapter") == false &&

stristr($param, "totalRows_chapter") == false) {

array_push($newParams, $param);

}

}

if (count($newParams) != 0) {

$queryString_chapter = "&" . htmlentities(implode("&", $newParams));

}

}

$queryString_chapter = sprintf("&totalRows_chapter=%d%s", $totalRows_chapter, $queryString_chapter);

?>

<?php echo $row_chapter['name']; ?>—<?php echo $row_system['name']; ?>—<?php echo $row_system['Author']; ?>

document.body.οnselect=document.body.οncοpy=document.body.οnmοuseup=function(){document.selection.empty();};

include "header.php"

?>

<?php echo $row_chapter['name']; ?>

分享到:
0
<?php echo $row_chapter['date']; ?>更新

$cid =$row_chapter['id'];//是你当前文章的编号

$sql_former = "select * from sls_wz where id

$sql_later = "select * from sls_wz where id>$cid "; //下一篇文章sql语句

$queryset_former = mysql_query($sql_former); //执行sql语句

if(mysql_num_rows($queryset_former)){ //返回记录数,并判断是否为真,以此为依据显示结果

$result = mysql_fetch_array($queryset_former);

echo " ".上一章." ". $result['name']."
";

} else {echo " ".这里是第一章哦."
";}

?>

  回目录  <?php

$cid =$row_chapter['id'];//是你当前文章的编号

$sql_former = "select * from sls_wz where id

$sql_later = "select * from sls_wz where id>$cid "; //下一篇文章sql语句

$queryset_later = mysql_query($sql_later);

if(mysql_num_rows($queryset_later)){

$result = mysql_fetch_array($queryset_later);

echo " ".下一章." ". $result['name']."
";

}

else {echo " ".下一章还没写哦."
";}

?>

评论列表

var uyan_config = {

'title':'<?php echo $row_chapter['name']; ?>',

'url':'http://diary.xiahuixin.com/chapter.php?id=<?php echo $row_chapter['id']; ?>',

};

include "footer.php"

?>

mysql_free_result($chapter);

mysql_free_result($system);

mysql_free_result($new_mood);

mysql_free_result($new_chapter);

mysql_free_result($pl);

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import requests import os from bs4 import BeautifulSoup class book_spider(): def __init__(self,root_url): self.root_url=root_url self.book_list=[] #一级页面中获取的数据(二级页面地址)存放于此列表 self.chapter_list=[] #二级页面中获取的数据(三级页面地址和章节名)存放于此列表 def get_url(url): while True: try: res=requests.get(url) if res.status_code==200: res.encoding =res.apparent_encoding print("页面获取成功") return res.text else: print("页面返回异常",res.status_code) except: print("页面获取错误") def get_book_list(self.url): res = self.get_url(url) html = BeautifulSoup(res,"html.parser") a_list = html.find_all("a",{"class":"name"}) for a in a_list: self.book_list.append(a["href"]) self.book_list = [self.root_url+i for i in self.bbok_list] self.book_list.remove('http://10.1.88.252:7000/庆余年') print(book_list) def get_chapter_list(self,url): res = self.get_url(url) html = BeautifulSoup(res,"html.parser") a_list = html.find_all("a",{"class":"chapter"}) for a in a_list: self.chapter_list.append((a["href"],a.text.replace("\n",""))) def get_content(self.chapter): url = self.root_url + chapter[0] print(url) book_name = chapter[0].split("/")[1] print(book_name) if not os.path.exists(book_name): os.mkdir(book_name) res = self.get_url(url) html = BeautifulSoup(res,"html.parser") content = html.find("div",{"id":"content"}).text print(content) path = os.path.join(book_name,chapter[1]) with open(path,"w",encoding="utf8") as f: f.write(content) def main(): self.get_book_list(self.root_url) for book in self.book_list: self.get_chapter_liat(book) for chapter in chapter_list: self.get_content(chapter) book_s = book_spider("http://10.1.88.252:7000") book_s.main()这是一段爬虫代码,找出里面的错误并改正
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值