今天声儿在上一篇文章中抢第100条评论没抢到,给了我一个灵感,就是抓取网站历史上第N条评论的作者,比如抓取第1000条评论的作者,也就是查询第1000条评论是谁发出的,找出谁是这个幸运之星~ 先上效果,(白色框框里面是鼠标放上去显示的title内容,也可以去小蝴蝶的
今天声儿在上一篇文章中抢第100条评论没抢到,给了我一个灵感,就是抓取网站历史上第N条评论的作者,比如抓取第1000条评论的作者,也就是查询第1000条评论是谁发出的,找出谁是这个幸运之星~
先上效果,(白色框框里面是鼠标放上去显示的title内容,也可以去小蝴蝶的留言板围观)

把如下代码扔到你想显示的地方即可
<?php $args = array( 'order' => 'ASC',//排序orderby的默认值是comment_date_gmt,所以只需调整order为倒序即可实现从旧往新输出 'number' => '1',//显示一条 'offset' => 99, //这里很重要,在本组函数中表示的意思是指在第一条评论之后99条的评论,也就是第100条 //'type' => 'comment', //如果你想仅仅统计不带pingbacks的评论,请把这句前面的//去掉 ); $comments = get_comments($args); foreach($comments as $comment) : echo('第100条:<a href="'.%20get_comment_link(%24comment->comment_ID).'" title="'.mysql2date('在Y-m-d说:',$comment->comment_date). strip_tags($comment->comment_content). '">'.$comment->comment_author.'</a>'); endforeach; ?>
用array是为了方便用注释给大家解释,如果大家喜欢短一点的,下面这段代码效果同上(是的,其实我就是想让文章更长一点,怎么地!)
<?php $comments = get_comments('number=1&offset=99&order=ASC'); foreach($comments as $comment) : echo('第100条:<a href="'. get_comment_link($comment->comment_ID).'" title="'.mysql2date('在Y-m-d说:',$comment->comment_date). strip_tags($comment->comment_content). '">'.$comment->comment_author.''); endforeach; ?>
好了,为了让这个功能派上用场,小蝴蝶即日起开展盖楼大赛(我好无聊哦),每第N000个幸运好基友都有机会....
上面省略号中的内容我想了很久无果,所以大家踊跃发言说说给什么福利比较好呢?
话说回来发言还是要发言的,但代码也是要看的哦,唔要本末倒置咗!
原文地址:抓取网站第N条评论的作者, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use