欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP乱入,post,mysql连接,抓取网页_PHP教程

程序员文章站 2022-05-12 11:09:19
...
post

 '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'].'
'; ?> '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'].'
'; ?>

mysql连接:

"; 
    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 '';
    echo '';

    // 显示字段名称
    echo "";
    for ($i=0; $i'.
      mysql_field_name($result, $i);
      echo "";
    }
    echo "";
    // 定位到第一条记录
    mysql_data_seek($result, 0);
    // 循环取出记录
    while ($row=mysql_fetch_row($result))
    {
      echo "";
      for ($i=0; $i';
        echo $row[$i];
        echo '';
      }
      echo "";
    }
   
    echo "
"; echo "
"; // 释放资源 mysql_free_result($result); // 关闭连接 mysql_close($conn); ?>

抓取网页:


抓取网页某个元素,使用simple_html_dom:



www.bkjia.comtruehttp://www.bkjia.com/PHPjc/735875.htmlTechArticlepost '0', 'pwd' => '1',);/*$pageContents = HttpClient::quickPost('http://xxxxxxxxx',$params);echo $pageContents;*/$client = new HttpClient('xxxxxx');$client->setDebug(true);$client...
相关标签: post mysql 连接