PHP乱入,post,mysql连接,抓取网页
2014-02-21 16:50
423 查看
post
<?php
header("content-type:text/html; charset=utf-8");
include ("util/HttpClient.class.php");
$params = array(
'usrname' => '0',
'pwd' => '1',
);
/*
$pageContents = HttpClient::quickPost('http://xxxxxxxxx',$params);
echo $pageContents;*/
$client = new HttpClient('xxxxxx');
$client->setDebug(true);
$client->post('/action',$params);
echo $client->getContent();
// foreach (json_decode($client->getContent(), true) as $item)
// echo $item['name'].'<br>';
?><?php
header("content-type:text/html; charset=utf-8");
include ("util/HttpClient.class.php");
$params = array(
'usrname' => '0',
'pwd' => '1',
);
/*
$pageContents = HttpClient::quickPost('http://xxxxxxxxx',$params);
echo $pageContents;*/
$client = new HttpClient('xxxxxx');
$client->setDebug(true);
$client->post('/action',$params);
echo $client->getContent();
// foreach (json_decode($client->getContent(), true) as $item)
// echo $item['name'].'<br>';
?>
mysql连接:
<?php
echo "This is a test</br>";
echo "asdfasdfadsf";
$mysql_server_name="xxxxx"; //数据库服务器名称
$mysql_username="root"; // 连接数据库用户名
$mysql_password="root"; // 连接数据库密码
$mysql_database="bookshop"; // 数据库的名字
// 连接到数据库
$conn=mysql_connect($mysql_server_name, $mysql_username,
$mysql_password);
// 从表中提取信息的sql语句
$strsql="SELECT * FROM `book`";
// 执行sql查询
$result=mysql_db_query($mysql_database, $strsql, $conn);
// 获取查询结果
$row=mysql_fetch_row($result);
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
// 显示字段名称
echo "</b><tr></b>";
for ($i=0; $i<mysql_num_fields($result); $i++)
{
echo '<td bgcolor="#000F00"><b>'.
mysql_field_name($result, $i);
echo "</b></td></b>";
}
echo "</tr></b>";
// 定位到第一条记录
mysql_data_seek($result, 0);
// 循环取出记录
while ($row=mysql_fetch_row($result))
{
echo "<tr></b>";
for ($i=0; $i<mysql_num_fields($result); $i++ )
{
echo '<td bgcolor="#00FF00">';
echo $row[$i];
echo '</td>';
}
echo "</tr></b>";
}
echo "</table></b>";
echo "</font>";
// 释放资源
mysql_free_result($result);
// 关闭连接
mysql_close($conn);
?>
抓取网页:
<?php
header("content-type:text/html; charset=gbk");
$url='http://ipanda3.taobao.com/';
$lines_string=file_get_contents($url);
echo $lines_string;
抓取网页某个元素,使用simple_html_dom:
<?php
header("content-type:text/html; charset=utf-8");
include ("util/HttpClient.class.php");
$params = array(
'usrname' => '0',
'pwd' => '1',
);
/*
$pageContents = HttpClient::quickPost('http://xxxxxxxxx',$params);
echo $pageContents;*/
$client = new HttpClient('xxxxxx');
$client->setDebug(true);
$client->post('/action',$params);
echo $client->getContent();
// foreach (json_decode($client->getContent(), true) as $item)
// echo $item['name'].'<br>';
?><?php
header("content-type:text/html; charset=utf-8");
include ("util/HttpClient.class.php");
$params = array(
'usrname' => '0',
'pwd' => '1',
);
/*
$pageContents = HttpClient::quickPost('http://xxxxxxxxx',$params);
echo $pageContents;*/
$client = new HttpClient('xxxxxx');
$client->setDebug(true);
$client->post('/action',$params);
echo $client->getContent();
// foreach (json_decode($client->getContent(), true) as $item)
// echo $item['name'].'<br>';
?>
mysql连接:
<?php
echo "This is a test</br>";
echo "asdfasdfadsf";
$mysql_server_name="xxxxx"; //数据库服务器名称
$mysql_username="root"; // 连接数据库用户名
$mysql_password="root"; // 连接数据库密码
$mysql_database="bookshop"; // 数据库的名字
// 连接到数据库
$conn=mysql_connect($mysql_server_name, $mysql_username,
$mysql_password);
// 从表中提取信息的sql语句
$strsql="SELECT * FROM `book`";
// 执行sql查询
$result=mysql_db_query($mysql_database, $strsql, $conn);
// 获取查询结果
$row=mysql_fetch_row($result);
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
// 显示字段名称
echo "</b><tr></b>";
for ($i=0; $i<mysql_num_fields($result); $i++)
{
echo '<td bgcolor="#000F00"><b>'.
mysql_field_name($result, $i);
echo "</b></td></b>";
}
echo "</tr></b>";
// 定位到第一条记录
mysql_data_seek($result, 0);
// 循环取出记录
while ($row=mysql_fetch_row($result))
{
echo "<tr></b>";
for ($i=0; $i<mysql_num_fields($result); $i++ )
{
echo '<td bgcolor="#00FF00">';
echo $row[$i];
echo '</td>';
}
echo "</tr></b>";
}
echo "</table></b>";
echo "</font>";
// 释放资源
mysql_free_result($result);
// 关闭连接
mysql_close($conn);
?>
抓取网页:
<?php
header("content-type:text/html; charset=gbk");
$url='http://ipanda3.taobao.com/';
$lines_string=file_get_contents($url);
echo $lines_string;
抓取网页某个元素,使用simple_html_dom:
相关文章推荐
- 一个关于if else容易迷惑的问题
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- 什么是设计模式
- PHP数据库长连接mysql_pconnect的细节
- Php Installing An Expansion
- PHP+Apache在Windows 9x下的安装和配置
- IIS 6 的 PHP 最佳配置方法
- 安装Apache和PHP的一些补充
- Linux Apache+MySQL+PHP
- 建立Apache+PHP+MySQL数据库驱动的动态网站
- PHP 5.3.0 安装分析心得
- apache 环境下 php 的配置注意事项
- ASP.NET、ASP、PHP、JSP之间有什么区别?
- PHP VBS JS 函数 对照表
- php xml 入门学习资料
- PHP简单系统数据添加以及数据删除模块源文件下载