file_get_contents()采集不到原因

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

file_get_contents()

服务器必须开启:allow_url_fopen = On

 

 

 
  1. <?php 
  2.     if(!ini_get('display_errors')){ 
  3.         ini_set('display_errors','On'); 
  4.     } 
  5.     error_reporting(E_ALL & ~E_NOTICE); 
  6.      
  7.     $con008=file_get_contents("http://www.baidu.com/"); 
  8.     $preg008='#<dt><a href="(.*)"  title="(.*)">(.*)</a></dt>#iUs'
  9.     preg_match_all($preg008,$con008,$arr008); 
  10.     $conn002=mysql_connect("localhost:6305","xxxx","xxxx"or die ("连接数据库服务器失败"); 
  11.     mysql_select_db("xxxx",$conn002); 
  12.     mysql_query("set names 'UTF-8'"); 
  13.     foreach($arr008[2] as $id=>$v){ 
  14.      
  15.         echo '<pre />'
  16.         print_r($v); 
  17.         echo '<pre />'
  18.      
  19.         $sql10="INSERT INTO `caiji_bkhot` (`id`, `title`, `url`) VALUES (NULL , '".iconv("UTF-8""GBK"$v)."' , '".iconv("UTF-8""GBK"$arr008[1][$id])."')"
  20.         mysql_query($sql10); 
  21.     } 
  22.     $last_id008= mysql_insert_id(); 
  23.     $sql11="delete from `caiji_bkhot` where id <= $last_id008 - 6"
  24.     mysql_query($sql11); 
  25. ?> 

 



      本文转自许琴 51CTO博客,原文链接:http://blog.51cto.com/xuqin/963386,如需转载请自行联系原作者



相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
29天前
|
编译器 API C语言
C/C++ 获取文件名的方法:分享一些实用的获取文件名的方法和技巧(__FILE__,__builtin_FILE(),__BASE_FILE__等)
C/C++ 获取文件名的方法:分享一些实用的获取文件名的方法和技巧(__FILE__,__builtin_FILE(),__BASE_FILE__等)
36 0
|
2月前
|
Java
cannot open shared object file: No such file or directory
cannot open shared object file: No such file or directory
21 0
|
5月前
指定的 filePath 文件不存在
指定的 filePath 文件不存在
21 2
|
9月前
ftok info: No such file or directory
ftok info: No such file or directory
102 0
perhaps your file is in a different file format and youneed to use a different restore operator?
perhaps your file is in a different file format and youneed to use a different restore operator?
98 0
FILE
FILE
89 0
|
Android开发
【错误记录】Android 文件查看错误 ( Error opening contents of device file ““: Cannot create directory )
【错误记录】Android 文件查看错误 ( Error opening contents of device file ““: Cannot create directory )
505 0
【错误记录】Android 文件查看错误 ( Error opening contents of device file ““: Cannot create directory )
Can‘t read file : End of file found 文件:txn_current、current svn无法正常读取文件
Can‘t read file : End of file found 文件:txn_current、current svn无法正常读取文件
Can‘t read file : End of file found 文件:txn_current、current svn无法正常读取文件
|
JavaScript
解决ecshop出现Warning: file_put_contents
解决ecshop出现Warning: file_put_contents
232 0
|
Python
6.2 file 写文件
#!/usr/bin/env python # -*- coding:utf-8 -*- #@Time      :2017/10/27 22:15 #@Author    :zhouyuyao #@File      :file_write.
665 0