我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP - file_get_contents跳过样式和脚本

I am trying to pull a html of a site,

I am using file_get_contents($url).

When I run file_get_contents then its takes too much time pull html of host site, Can I skip style, scripts and images ?

I think then it will take less time to pull html of that site.

Try:

$file = file_get_contents($url);
$only_body = preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $file);

近期文章

  • 如何在php中使用Flow Player的while循环?
  • 在多维数组中用值替换值
  • 仅限PHP GD:PNG24 + Alpha => PNG8不保存Alpha
  • 如何使用Simple HTML dom解析器回显innertext
  • 如何在php中创建具有动态名称的函数
  • 如何根据相关表的结果选择MySQL记录?
  • EDEN Framework与Zend Framework一起使用:无法重新声明类Eden_Class
  • ForEach仅执行一次任务
  • 从某个元素名称解析文本文件,直到使用PHP找到另一个元素名称
  • 正则表达式删除xx。 从一个字符串的开头但只有2位数(代码完成一半)
  • 元刷新时无限重载
  • 如何从php运行bash脚本?
  • 在PHP中删除for循环中的重复项
  • php中的路径无法正常工作
  • 从cron脚本编写crontab会返回127错误
  • 将动态值放在$ _POST中
  • HTML表类的空数据数组
  • 可靠地清理电子邮件正文编码
  • 创建joomla模块以执行简单查询并显示结果
  • 将C#datetime转换为php mysql [关闭]

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华