<?php // 正则提取网页超链接 function get_links($str) { preg_match_all("'<\s*a\s.*?href\s*=\s*([\"\'])?(?(1)(.*?)\\1|([^\s\>]+))[^>]*>?(.*?)</a>'isx",$str,$links); while(list($key,$val) = each($links[2])) { if(!empty($val)) $links2[] = $val; } return $lin...
<?php //date_default_timezone_set ("PRC");//设置时区 //set_time_limit(0); //header('Access-Control-Allow-Origin:*');//允许所有来源访问 //header('Access-Control-Allow-Method:POST,GET');//允许访问的方式 include_once "csv.php"; //到这里 http://www.180it.com/archives/1832/ include_once "functio...
include_once "config.php"; include_once "db.php"; include_once "function.php"; $txt_array = glob("*.{txt,dat}",GLOB_BRACE); $txt = array_rand($txt_array); $file= $txt_array[0]; $strdate= explode("_",$file)[0]; //echo(strtotime($strdate)); //e...
$preg= '/xue[\s\S]*?om/i'; preg_match_all($preg,"学并思网址xuebingsi.com",$res); var_dump($res[0][0]);
本段代码是正则获取内容中的所有连接地址,这个在采集的时候经常用到$con= file_get_contents($url); $pattern = '/<a(?:.*?)href="(((?:http(?:s?):\/\/)?([^\"\/]+))?(?:[^\"]*))"(?:[^>]*?)>([^<]*?)<\/a>/i'; preg_match_all($pattern, $con, $links); $links = array_flip(array_flip($links[1])); 来源:http:...
<?php date_default_timezone_set ("PRC");//设置时区 set_time_limit(0); header('Access-Control-Allow-Origin:*');//允许所有来源访问 header('Access-Control-Allow-Method:POST,GET');//允许访问的方式 header("Content-type:text/html;charset=utf-8"); // 请求示例 url 默认请求参数已经URL编码处理 $method = "GET&qu...
ESP32 Micropython编程(Thonny)GPIO输入输出GPIO输入输出一、输入输出GPIO口定义及使用硬件输入:按键输出:led2.软件即程序①输入输出定义import machine led = machine.Pin(2,machine.Pin.OUT) #定义led为输出 sw = machine.Pin(0,machine.Pin.IN) #定义sw为输入或者import machine from machine import Pin #导入GPIO模块 #创建GPIO对象 led = Pin(2) #led = Pin(2, Pin.OUT) #l...
ESP32 Micropython编程(Thonny)定时器Timer定时器的基本使用一、定时器的基本使用使用回调函数import machine led = machine.Pin(2,machine.Pin.OUT) tim0 = machine.Timer(0) #创建定时器对象 tim0~3 共四个类 def handle_callback(timer): #定时器中断服务函数 led.value( not led.value() ) tim0.init(period=500, mode=machine.Timer.PERIODIC, callback=handle_ca...
ESP32 Micropython编程(Thonny)多任务处理多任务处理一、简单blink程序import machine import time led = machine.Pin(2,machine.Pin.OUT) #定义led为输出 while True: led.on() time.sleep(0.5) # sleep is a blocking code 阻塞代码 运行时候无法执行其他操作 led.off() time.sleep(0.5) 上述程序中的time.sleep()是阻塞代码(即在此程序运行过程中,无法进行其他操作)补充:...
ESP32 Micropython编程(Thonny)UART串口通讯uart串口通讯一、串口硬件ESP32-WROOM-32 有(0,1,2)三个串口端UART0: GPIO3(RXD)和GPIO1(TXD) 用于下载调试串口,引脚不可改变UART1: GPIO9(RXD)和GPIO10(TXD) 外接flash,使用时候请设置其他引脚连接UART2: GPIO16(RXD)和GPIO17(TXD) 可以直接使用使用时候将 UART2 通过USB转TTL芯片 接到计算机二、基本程序在shell终端输入依次输入以下代码>>> import machine >>...