php采集的数据保存 php 采集

PHP怎样把得到的数据的值保存在一个数组里面input 存在着2个方式 get 和post  , 你可以根据你的需求去选择 。
现在很多框架都支持直接将post或者get到的数据作为整个数组保存哈
$input_array = $_GET['paramsName'];
参考链接:
php保存数据到数据库需要转义一下 。有几个办法:
1,最简单 , 把一些危险字符过滤掉,比如英文的单引号 , 双引号等php采集的数据保存;
2 , 使用addslashes在php中进行转义,自己处理php采集的数据保存;
3 , 可以使用一些现成的处理方法,比如uchome自带的getstr 。这样的好处就是对各种可能出现的情况处理比较好 。
抓取网页数据怎么保存到数据库 php给一个例子php采集的数据保存你看看吧.
if($pro_list_contents=@file_get_contents(''))
{
preg_match_all("/td width=\"50%\" valign=\"top\"(.*)td width=\"10\"img src=https://www.04ip.com/"images\/spacer.gif\"/isU", $pro_list_contents, $pro_list_contents_ary);
for($i=0; $icount($pro_list_contents_ary[1]); $i++)
{
preg_match_all("/a href=https://www.04ip.com/"(.*)\"img src=https://www.04ip.com/"(.*)\".*span(.*)\/span/isU", $pro_list_contents_ary[1][$i], $url_img_price);
$url=addslashes($url_img_price[1][0]);
$img=str_replace(' ', '20%', trim(''.$url_img_price[2][0]));
$price=(float)str_replace('$', '', $url_img_price[3][0]);
preg_match_all("/a class=\"ml1\" href=https://www.04ip.com/".*\"(.*)\/a/isU", $pro_list_contents_ary[1][$i], $proname_ary);
$proname=addslashes($proname_ary[1][0]);
include("inc/db_connections.php");
$rs=mysql_query("select * from pro where Url='$url' and CateId='{$cate_row['CateId']}'"); //是否已经采集php采集的数据保存了
if(mysql_num_rows($rs))
{
echo "跳过php采集的数据保存:{$url}br";
continue;
}
$basedir='/u_file/pro/img/'.date('H/');
$save_dir=Build_dir($basedir); //创建目录函数
$ext_name = GetFileExtName( $img); //取得图片后辍名
$SaveName = date( 'mdHis' ) . rand( 10000, 99999 ) . '.' . $ext_name;
if( $get_file=@file_get_contents( $img ) )
{
$fp = @fopen( $save_dir . $SaveName, 'w' );
【php采集的数据保存 php 采集】@fwrite( $fp, $get_file );
@fclose( $fp );
@chmod( $save_dir . $SaveName, 0777 );
@copy( $save_dir . $SaveName, $save_dir . 'small_'.$SaveName );
$imgpath=$basedir.'small_'.$SaveName;
}
else
{
$imgpath='';
}
if($pro_intro_contents=@file_get_contents($url))
{
preg_match_all("/\/h1(.*)\/td\/tr/isU", $pro_intro_contents, $pro_intro_contents_ary);
$p_contents=addslashes(str_replace('src="', 'src="', $pro_intro_contents_ary[1][0]));
$p_contents=SaveRemoteImg($p_contents, '/u_file/pro/intro/'.date('H/')); //把远程html代码里的图片保存到本地
}
$t=time();
mysql_query("insert into pro(CateId, ProName, PicPath_0, S_PicPath_0, Price_0, Contents, AddTime, Url) values('{$cate_row['CateId']}', '$proname', '$imgpath', '$img', '$price', '$p_contents', '$t', '$url')");
echo $url.$img.$cate."br\r\n";
}
}
PHP怎么将表格的数据保存到数据库看你的表格,只需要从表单中循环取出所有行,然后依次写入数据库就行了
假设表单中是:txt1[] txt2[]......
通过$a=$_POST["txt1[]"]取得值,然后循环写入:
for($t=0;$t=count($a)-1;$t++){
// insert into 表 (字段1,......) values ('$a[$t]',.....)
}
至于打?。贘S中直接windows.print就行了
php session 数据保存在哪里?当然是在服务器端,但不是保存在内存中 , 而是保存在文件或数据库中 。
默认情况下,php.ini
中设置的
SESSION
保存方式是

推荐阅读