也谈截取首页新闻
有很多截取首页新闻的程序,但是并不能成功。
他们的工作原理无非两种,一种是采用某些网站称之为backend的后端数据库接口,另一种则是硬声声的根据html代码截取。本程序采用的是后者。应该说,容错性能比较好。
$open = fopen("http://www.yahoo.com.cn/index.html", "r");//网页地址
$read = fread($open, 15000);
fclose($open);
$search = eregi("(.*)", $read, $printing);//截取一段源代码,最好先分析一下源代码
//以下开始取出容余源代码
$printing[1] = str_replace("href=\"/homer/?", "href=\"", $printing[1]);
$printing[1] = str_replace("href=\"/headlines/fullcoverage/", "href=\"http://www.yahoo.com.cn/headlines/fullcoverage/", $printing[1]);
$printing[1] = str_replace("
$printing[1] = str_replace("
$printing[1] = str_replace(" class=sbody", "", $printing[1]);
$printing[1] = str_replace("", "", $printing[1]);
$content = $printing[1];
$content = explode("-", $content);
$headlines = sizeof($content);
for ($i = 0; $i
print "新闻".($i+1).") : $content[$i]
";//激动人心的时刻到了!显示出来了!
}
?>
在php3/php4 apache下调试通过。

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

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



MySQL is a commonly used relational database management system that provides a variety of functions to process and operate data. Among them, the REPLACE function is used to replace the specified part of the string. In this article, we will introduce how to use the REPLACE function for string replacement in MySQL and demonstrate its usage through code examples. First, let’s take a look at the syntax of the REPLACE function: REPLACE(str,search_str,replace_str).

What are the string search and replace techniques in Python? (Specific code example) In Python, strings are a common data type, and we often encounter string search and replace operations in daily programming. This article will introduce some common string search and replacement techniques, accompanied by specific code examples. To find a specific substring in a string, you can use the find() method or index() method of the string. The find() method returns the index of the first occurrence of the substring in the string.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Everyone is looking forward to today's Windows 1123H2 release. In fact, Microsoft has just launched updates to the release preview, which is the closest channel before the official release stage. Known as Build 22631, Microsoft said they are rolling out the new rebranded chat app, phone link, and play together widgets that have been tested on other internal channels over the past few months. "This new update will have the same servicing branch and codebase as Windows 11 version 22H2 and will be cumulative with all newly announced features, including Copilot in Windows (preview)," Microsoft promises. Redmond officials further

Detailed explanation of CSS content attributes: content, counter and quotesCSS (cascading style sheets) is an integral part of front-end development. It can help us beautify web pages and enhance user experience. In CSS, there are some special properties that can be used to control the display of text content, including content, counter, and quotes. This article explains these properties in detail and provides specific code examples. 1. content attribute content attribute

In Java, use the replace() method of the StringBuilder class to replace part of the content in a string. In Java programming, strings are a very important data type, and strings often need to be processed and manipulated. And sometimes we need to replace part of the string to meet our needs. In Java, you can use the replace() method of the StringBuilder class to implement string replacement operations. StringBuilder is a

请问如何修改url某一参数的参数值呢?是要拆开了再拼回去吗?那么请问如何修改url某一参数的参数值呢?是要拆开了再拼回去吗?http://127.0.0.1/myo/newuser.php?mod=search&type=fastone比如现在我要修改mod=new要怎么做呢?------解决方案--------------------发送了请求

In an interview with CNBC's Andrew Ross Sorkin, Microsoft AI CEO Mustafa Suleymanexpressed his understanding of web copyright law. Suleyman says that content that is accessible on the open web is "freeware," and anyone can copy it, reproduc
