成都网站建设设计

将想法与焦点和您一起共享

php抓取网站商城数据库 php获取网页

php如何获取数据库信息

代码如下:?View Code PHP include("conn.php");//调用数据库连接文件 echo "table width=572 height=56 border=0 cellspacing=1 "; //创建html表格 echo "tr bgcolor=#9999FF"; echo "th width=33 scope=colid/th"; echo "th width=100 scope=coluser_name/th "; echo "th width=100 scope=coluser_pass/th "; echo "th width=100 scope=colstaus/th"; echo "th width=100 scope=colinsert_time/th"; echo "/tr"; $SQL = "select * from user_info"; $query = mysql_query($SQL); //SQL查询语句 while ($row = mysql_fetch_array($query)){ //使用while循环mysql_fetch_array()并将数据返回数组 echo "tr onmouseout=this.style.backgroundColor='' onMouseOver=this.style.backgroundColor='#99CC33' bgcolor=#CCCCCC"; echo "td$row[0]/td"; //输出数组中数据 echo "td$row[1]/td"; echo "td$row[2]/td"; echo "td$row[3]/td"; echo "td$row[4]/td"; echo "/tr"; } echo "/table";输出记录截图

创新互联公司专业为企业提供坡头网站建设、坡头做网站、坡头网站设计、坡头网站制作等企业网站建设、网页设计与制作、坡头企业网站模板建站服务,10年坡头做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

php怎么抓取其它网站数据

可以用以下4个方法来抓取网站 的数据:

1. 用 file_get_contents 以 get 方式获取内容:

?

$url = '';

$html = file_get_contents($url);

echo $html;

2. 用fopen打开url,以get方式获取内容

?

$url = '';

$fp = fopen($url, 'r');

stream_get_meta_data($fp);

$result = '';

while(!feof($fp))

{

$result .= fgets($fp, 1024);

}

echo "url body: $result";

fclose($fp);

3. 用file_get_contents函数,以post方式获取url

?

$data = array(

'foo'='bar',

'baz'='boom',

'site'='',

'name'='nowa magic');

$data = http_build_query($data);

//$postdata = http_build_query($data);

$options = array(

'http' = array(

'method' = 'POST',

'header' = 'Content-type:application/x-www-form-urlencoded',

'content' = $data

//'timeout' = 60 * 60 // 超时时间(单位:s)

)

);

$url = "";

$context = stream_context_create($options);

$result = file_get_contents($url, false, $context);

echo $result;

4、使用curl库,使用curl库之前,可能需要查看一下php.ini是否已经打开了curl扩展

$url = '';

$ch = curl_init();

$timeout = 5;

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

$file_contents = curl_exec($ch);

curl_close($ch);

echo $file_contents;

如何获取数index.php网站如何获取数据库

认要显示15条数据,因此,我们先从数据库取开始的15条数据显示在页面。后面新加载的数据,我们也按每次15条的方式展示。

为了讲解尽量简单,我使用原生的PHP和mysql查询语句。首先,需要连接数据库,包含连接信息的connnect.php。这里我定义了几个用户id。

然后查询数据表,获得结果集,并循环输出,代码如下:

php

require_once('connect.php');

$user = array('demo1','demo2','demo3','demo3','demo4');

$amp;amp;$nbsp;

div id="container"$amp;amp;$nbsp;

php

PHP获取网站中的信息并存入数据库

用PHP自带函数就可以实现,首先要过去对方的网页信息,用

file_get_contents();参数是对方的URL地址,这个函数返回是一个字符串你想要的东西就在这个字符串中了

接下来就可以针对这个字符串做处理了,说下思路,正如你这个问题想获取到航班号起飞时间,在这个网页中应该有很多相同的标签元素,它们都有共同点,用

用正则表达式preg_match();或者是

preg_match_all();这两个函数它们都返回一个数组,这个数组存的就是你要的航班号和起飞时间,那么相同信息的数组就会出现了,然后在对这个数组进行分析找到你要的某个值或全部的值

获取信息要用到的3个函数是:

file_get_contents();

preg_match();

preg_match_all();

如何用php获取数据库信息并显示

获取ppq数据库的所有表名的代码:

?php

$server='localhost';

$user='root';

$pass='12345';

$dbname='ppq';

$conn=mysql_connect($server,$user,$pass);

if(!$conn)

die("数据库系统连接失败!");

$result=mysql_list_tables($dbname);

if(!$result)

die("数据库连接失败!");

while($row=mysql_fetch_row($result))

{

echo

$row[0]."

";

}

mysql_free_result($result);

?

mysql_list_tables

(PHP

3,

PHP

4

,

PHP

5)

mysql_list_tables

--

列出

MySQL

数据库中的表

说明

resource

mysql_list_tables

(

string

database

[,

resource

link_identifier])

mysql_list_tables()

接受一个数据库名并返回和

mysql_query()

函数很相似的一个结果指针。用

mysql_fetch_array()或者用mysql_fetch_row()来获得一个数组,数组的第0列就是数组名,当获取不到时

mysql_fetch_array()或者用mysql_fetch_row()返回

FALSE。


名称栏目:php抓取网站商城数据库 php获取网页
标题来源:http://chengdu.cdxwcx.cn/article/hgjpjp.html