php获取某个网站了内容 并且保存为TXT 下次直接从txt读取
php获取某个网站了内容 并且保存为TXT 下次直接从txt读取
file_put_contents 好像可以保存!
具体怎么写! 不会写啊!
代码如下!
<?php function get_flash_url( $url ) { $lines = file($url); foreach ($lines as $linenum=> $line) { preg_match_all('|<title>([^<>]+)</title>|',$line,$result); $swfurl=$result[1][0]; if(!empty($swfurl)) return $swfurl; } } ?><?php $url=$_SERVER["QUERY_STRING"]; $flashurl= get_flash_url($url); echo preg_replace("/[&,?]/","",$flashurl);?>
回复讨论(解决方案)
这个取得了flash的路径 完后你要把路径给写到一个text内?
。。写个完整的拉啊! 不会啊!
你是要将
echo preg_replace("/[&,?]/","",$flashurl);
的结果写到文件里吗?
$s = preg_replace("/[&,?]/","",$flashurl);
file_put_contents('文件名.txt', $s);
回复楼上
:
我想
$s = preg_replace("/[&,?]/","",$flashurl); //这获取结果
file_put_contents('news.txt', $s);/ /然后 保存 到txt 里 这里!缓存
// 因为 获取内容 很多! flashurl如果 获取了 一个 news.txt保存了下来 flashurl在 获取其他的内容 之前保存的会 被 覆盖了!news.txt 里的内容 这个我测试过!
// 保存下来之后! http://bbs.csdn.net/1.php?http://bbs.csdn.net/topics/
比如这样! 内容保存下来了! 在次访问这个地址的时候! 不在 http://bbs.csdn.net/topics/ 这获取内容 直接重 news.txt保存下来的内容里获取!
// 因为 获取内容 很多! flashurl如果 获取了 一个 news.txt保存了下来 flashurl在 获取其他的内容 之前保存的会 被 覆盖了!news.txt 里的内容 这个我测试过! 这个 怎么解决 把 没个获取下来的数据都保存到一个txt 或者 超过 几MB后! 重新生成 文件 news.txt news2.txt 这样! 要把没个地址 获取下来的内容都保存! 然后下次 在访问 同一个 地址的时候! 保存下来之后! http://bbs.csdn.net/1.php?http://bbs.csdn.net/topics/
比如这样! 内容保存下来了! 在次访问这个地址的时候! 不在 http://bbs.csdn.net/topics/ 这获取内容 直接重 news.txt保存下来的内容里获取!
不是有追加方式吗?
你只要认真看一下 file_pu_contents 函数的说明,你的疑问就不复存在了
真正需要思考的是:当多组数据存放在一个文件中时,你如何把他们分开

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



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo
