


PHP collects the reading ranking of CSDN blog sidebar_PHP tutorial
PHP collects the reading ranking of CSDN blog sidebar
The collected data will be used in the project, so I tried it on the CSDN blog first. The Simple HTML DOM (official website) library is used here, which can conveniently traverse HTML documents.

<?php include_once('simple_html_dom.php'); header('Content-Type:text/html;charset=utf-8'); $html = file_get_html('http://blog.csdn.net/szy361'); $res = $html->find('#hotarticls ul.panel_body li a[title]');//取得id=hotarticls下class为panel_bodya的ul标签下的a的title $span = $html->find('#hotarticls ul.panel_body li span');//取得span foreach($res as $element){ $arr[] = $element->title.'+'.$element->href;//将title值和href的值通过+连起来 } foreach($span as $e){ $brr[] = $e->innertext;//得到span下的值组成的数组 } //将两个数组组成一个新的二维数组 for($i=0;$i<count($res);$i++){ $crr[] = explode('+',$arr[$i]); $crr[$i][] = $brr[$i]; } return $crr;

Extension:
Getting started with PHP Simple HTML DOM parser

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Starting from scratch, I will teach you step by step how to install Flask and quickly build a personal blog. As a person who likes writing, it is very important to have a personal blog. As a lightweight Python Web framework, Flask can help us quickly build a simple and fully functional personal blog. In this article, I will start from scratch and teach you step by step how to install Flask and quickly build a personal blog. Step 1: Install Python and pip Before starting, we need to install Python and pi first

Blog, also translated as web log, blog or blog, is a website that is usually managed by individuals and posts new articles from time to time. So how to set up a blog? What are the PHP blog systems? Which blogging system is best to use? Below, PHP Chinese website will summarize and share the top ten open source PHP blog systems with you. Let’s take a look!

With the development of the Internet, blogs have become a platform for more and more people to share their lives, knowledge and ideas. If you also want to create a blog of your own, then this article will introduce how to use PHP and SQLite to create a simple blog. Determine the needs Before starting to create a blog, we need to determine the functions we want to achieve. For example: Create a blog post Edit a blog post Delete a blog post Display a list of blog posts Display blog post details User authentication and permission control Install PHP and SQLite We need to install PHP and S

With the popularity of the Internet, blogs play an increasingly important role in information dissemination and communication. In this context, more and more people are starting to build their own blog sites. This article will introduce how to use the PythonDjango framework to build your own blog website. 1. Introduction to the PythonDjango framework PythonDjango is a free and open source web framework that can be used to quickly develop web applications. The framework provides developers with powerful tools to help them build feature-rich

How to create a simple blog using PHP 1. Introduction With the rapid development of the Internet, blogs have become an important way for people to share experiences, record life and express opinions. This article will introduce how to use PHP to create a simple blog, with specific code examples. 2. Preparation Before starting, you need to have the following development environment: a computer with a PHP interpreter and Web server (such as Apache) installed, a database management system, such as MySQL, a text editor or IDE3

You can create a blog by determining the topic and target audience of the blog, choosing a suitable blogging platform, registering a domain name and purchasing hosting, designing the appearance and layout of the blog, writing quality content, promoting the blog, and analyzing and improving it.

This article will introduce in detail how to install and build a blog on CentOS system, including the required software installation, configuration and basic usage. At the end of the article, I will share a little Linux knowledge. With the continuous development of Internet technology, more and more people choose to use blogs to record their lives and share knowledge. As a popular Linux distribution, CentOS is stable and secure and is suitable for building blogs. This article will Detailed introduction to the steps of installing and setting up a blog on CentOS. Preparation before installation 1. Make sure that the CentOS operating system has been installed and can be connected to the Internet. 2. Have basic knowledge of Linux command line operations. Install Apache server 1. Open the terminal and use the following command

GolangWebsocket Development Guide: Implementing the Multi-person Online Blog Function In today's era of developed Internet, blogs have become an important tool for people to share their opinions and knowledge. In order to improve user experience, implementing multi-person online blogging has become a requirement for many websites. This article will introduce how to use Websocket technology in Golang to implement this function, and give specific code examples. Websocket is a new communication protocol in HTML5, which allows servers and browsers to
