简单的信息采集程序示例(小偷程序) (转)

简单的信息采集程序示例(小偷程序)

最近正准备做一个信息采集的程序,下面是一个简单的采集程序,提供给初学者入门参考。

aspx页面代码
       < asp:TextBox ID = " Txt_Url "  runat = " server "  Width = " 441px " ></ asp:TextBox >< br  />  
   
< asp:Button id = " Btn_GetUrlSource "  runat = " server "  Text = " 取得网页代码 "  OnClick = " Btn_GetUrlSource_Click " ></ asp:Button >
   
< br  />  
   
< asp:TextBox id = " Txt_UrlSource "  runat = " server "  Width = " 100% "  Height = " 195px "  TextMode = " MultiLine " ></ asp:TextBox >< br  />
      
< br  />
采集开始代码
      
< asp:TextBox ID = " Txt_First "  runat = " server "  Height = " 90px "  TextMode = " MultiLine "  Width = " 280px " ></ asp:TextBox >< br  />
      
< asp:Button ID = " Btn_ListCheck "  runat = " server "  OnClick = " Btn_ListCheck_Click "  Text = " 测试唯一性 "   />< br  />
采集结束代码      
< asp:TextBox ID = " Txt_Last "  runat = " server "  Height = " 90px "  TextMode = " MultiLine "
          Width
= " 280px " ></ asp:TextBox >< br  />
      
< br  />
      
< asp:Button ID = " Btn_Result "  runat = " server "  Text = " 取得采集结果 "  OnClick = " Btn_Result_Click "   />< br  />
      
< asp:TextBox ID = " Txt_Result "  runat = " server "  Height = " 134px "  TextMode = " MultiLine "  Width = " 579px " ></ asp:TextBox >

.cs页面代码
using  System;
using  System.Collections;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Web;
using  System.Web.SessionState;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.HtmlControls;
using  System.IO;
using  System.Net;
using  System.Text.RegularExpressions;
using  NetShuai.Database;


 
private   string  PageUrl  =   "" ;

    
private   void  Page_Load( object  sender, System.EventArgs e)
    
{
        
        
// 在此处放置用户代码以初始化页面 
    }



    
protected   void  Btn_GetUrlSource_Click( object  sender, EventArgs e)
    
{
        PageUrl 
= Txt_Url.Text;
        WebRequest request 
= WebRequest.Create(PageUrl);
        WebResponse response 
= request.GetResponse();
        Stream resStream 
= response.GetResponseStream();
        StreamReader sr 
= new StreamReader(resStream, System.Text.Encoding.Default);
        Txt_UrlSource.Text 
= sr.ReadToEnd();
        resStream.Close();
        sr.Close();
    }

    
protected   void  Btn_Result_Click( object  sender, EventArgs e)
    
{
        
string strExp;
        strExp 
= @"(?<=" + Server.HtmlEncode(Txt_First.Text) + ")[\w\W]*?(?=" + Server.HtmlEncode(Txt_Last.Text) + ")";
        MatchCollection mc 
= Regex.Matches(Server.HtmlEncode(Txt_UrlSource.Text), strExp);
        
for (int i = 0; i < mc.Count; i++)
        
{
            Txt_Result.Text 
+=Server.HtmlDecode(mc[i].Value);
        }

       
    }

    
protected   void  Btn_ListCheck_Click( object  sender, EventArgs e)
    
{
        
string strExp;
        strExp 
= Server.HtmlEncode(Txt_First.Text);
        MatchCollection mc 
= Regex.Matches(Server.HtmlEncode(Txt_UrlSource.Text), strExp);
        
if(mc.Count>1)
        
{
            Response.Write(
"<script>alert('列表开始代码有重复!')</script>");
            
return;
        }


        strExp 
= Server.HtmlEncode(Txt_Last.Text);
        mc 
= Regex.Matches(Server.HtmlEncode(Txt_UrlSource.Text), strExp);
        
if (mc.Count > 1)
        
{
            Response.Write(
"<script>alert('列表结束代码有重复!')</script>");
            
return;
        }

    }

转载于:https://www.cnblogs.com/zhangzheny/archive/2007/09/21/901722.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的STM32温度采集程序示例。 首先,需要在STM32上配置ADC模块,用于模拟信号的采集。具体配置方法可以参考STM32官方文档和相关教程。 然后,在程序中需要引入相关的头文件和宏定义: ```c #include "stm32f10x.h" #include <stdio.h> #define ADC1_DR_Address ((uint32_t)0x4001244C) ``` 其中,`ADC1_DR_Address`为ADC数据寄存器地址。 接着,需要初始化ADC模块和GPIO模块,配置输入输出模式和采样时间等参数: ```c void ADC_Configuration(void) { ADC_InitTypeDef ADC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_ADC1, ENABLE); RCC_ADCCLKConfig(RCC_PCLK2_Div6); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); ADC_DeInit(ADC1); ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode = DISABLE; ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 1; ADC_Init(ADC1, &ADC_InitStructure); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_239Cycles5); ADC_Cmd(ADC1, ENABLE); ADC_ResetCalibration(ADC1); while (ADC_GetResetCalibrationStatus(ADC1)); ADC_StartCalibration(ADC1); while (ADC_GetCalibrationStatus(ADC1)); } ``` 其中,`GPIO_InitStructure.GPIO_Pin`为GPIO引脚编号,`ADC_InitStructure.ADC_ContinuousConvMode`为ADC连续换模式,`ADC_RegularChannelConfig`为ADC常规通道配置函数。 最后,在主函数中进行温度采集和计算: ```c int main(void) { uint16_t adc_value; float temperature; ADC_Configuration(); while(1) { ADC_SoftwareStartConvCmd(ADC1, ENABLE); while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC)); adc_value = ADC_GetConversionValue(ADC1); temperature = (adc_value * 3.3 / 4096.0 - 0.76) / 0.0025 + 25; printf("Temperature: %.2fC\n", temperature); } } ``` 其中,`adc_value`为采集到的模拟信号值,`temperature`为计算得到的温度值。 以上就是一个简单的STM32温度采集程序示例。需要注意的是,实际应用中可能需要进行更多的配置和优化,例如滤波、校准等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值