检测远程URL是否存在的三种方法

本文用3种方法检测远程URL是否存在。

private void Page_Load(object sender, System.EventArgs e)
{

 string url1 = "http://dotnet.aspx.cc/";
 string url2 = "http://dotnet.aspx.cc/Images/logo.gif";
 Response.Write("<li>方法1:");
 Response.Write(url1 + " 存在:" + UrlExistsUsingHttpWebRequest(url1).ToString());
 Response.Write("<li>方法2:");
 Response.Write(url1 + " 存在:" + UrlExistsUsingSockets(url1).ToString());   
 Response.Write("<li>方法3:");
 Response.Write(url1 + " 存在:" + UrlExistsUsingXmlHttp(url1).ToString());

 Response.Write("<li>方法1:");
 Response.Write(url2 + " 存在:" + UrlExistsUsingHttpWebRequest(url2).ToString());
 Response.Write("<li>方法3:");
 Response.Write(url2 + " 存在:" + UrlExistsUsingXmlHttp(url2).ToString());
}
private bool UrlExistsUsingHttpWebRequest(string url)
{
 try
 {
  System.Net.HttpWebRequest myRequest =(System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
  myRequest.Method = "HEAD";
  myRequest.Timeout = 100;
  System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)myRequest.GetResponse();
  return (res.StatusCode == System.Net.HttpStatusCode.OK);
 }
 catch(System.Net.WebException we)
 {
  System.Diagnostics.Trace.Write(we.Message);
  return false;
 }
}
private bool UrlExistsUsingXmlHttp(string url)
{
 //注意:此方法需要引用Msxml2.dll
 MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass();
 _xmlhttp.open("HEAD",url,false,null,null);
 _xmlhttp.send("");
 return (_xmlhttp.status == 200 );
}

private bool UrlExistsUsingSockets(string url)
{
 if(url.StartsWith("http://")) url = url.Remove(0,"http://".Length);
 try
 {
  System.Net.IPHostEntry ipHost = System.Net.Dns.Resolve(url);
  return true;
 }
 catch (System.Net.Sockets.SocketException se)
 {
  System.Diagnostics.Trace.Write(se.Message);
  return false;
 }
}

【Qt图书管理系统】5.完整版源码及下载地址 Qt图书管理系统完整源码下载。 阅读详情

相关推荐

EBS开发_离散工单创建API

--以下代码于20171213在TONY环境中实现 DECLARE     l_iface_rec    wip.wip_job_schedule_interface%ROWTYPE; --工单任务接口表     l_group_id     NUMBER;     l_returnstatus VARCHAR2(40);     l_errormsg     VARCHAR2(2000

蜗牛先生快跑的博客 2596

检查url的可用性

文章目录前言脚本总结 前言 此脚本源于一个学员的刷流量脚本,刷流量脚本使用的是ab命令,但效果似乎并不好,使用ab压测有点大材小用,而且还容易被封号,所以做了下改进,改为公司常用的判断网站是否存活的脚本。 脚本 #!/bin/bash url() { HTTP_CODE=$(curl -o /dev/null --connect-timeout 3 -s -w "%{http_code}" $1 ) if [ $HTTP_CODE -ne 200 ]; then echo "Wa

Shi的博客 745

【无人机对抗】基于matlab无人机红蓝对抗仿真【含Matlab源码 4436期】

无人机红蓝对抗仿真 完整代码,包运行;可提供运行操作视频!适合小白!

Matlab3024528700的博客 1383

JS实现检测目标网址是否可访问 网址存活检测

最近有用户建议给尊云网站分类目录增加一个网址存活检测在功能。检测目标网址是否存活一边坚持目标网址在状态码就可以了。但实际测试给一个不存在的网址无法正确判断。网上有人 通过onerror来实现。

天下的博客 2896

NHANES数据库的介绍及使用(一)

一、数据库概况 NHANES(National Health and Nutrition Examination Survey)是一项旨在评估美国成人和儿童健康和营养状况的研究计划,计划始于20世纪60年代初期,是一项针对不同人群或健康主题的调查。 1999年该调查成为一项持续计划,涉及各种健康和营养测量,项目每年调查一个全国代表性的样本,约5000人,这些人群位于全国各县,每年对其中15个县进行访问。 NHANES访谈部分包括人口统计学、社会经济学、饮食和健康相关问题。体检部分包括生理测量、实验室检查等

Christina 5万+

RGB接口电容触摸屏驱动(一)模块介绍

RGB接口电容触摸屏驱动(一)模块介绍

杰克拉力船长个人博客 7880

hutool判断各种类型数据

hutool判断各种类型数据 参考:https://www.cnblogs.com/name-lizonglin/p/13509311.html package com.sherlock.common.utils; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.co

SherlockerSun的博客 5599

K8s私有仓库拉取镜像报错解决:x509 certificate signed by unknown authority

在Kubernetes环境中使用自签名证书的私有Harbor镜像仓库时,常会遇到证书验证失败的问题。本文将详细讲解如何解决这个常见的证书问题。Kubernetes版本:1.28.2容器运行时:containerd 1.6.20私有仓库:Harbor(使用自签名证书)(超简单搭建私有仓库Harbor-亲测无坑解决K8s私有仓库证书问题的关键在于正确配置容器运行时(本例中是containerd)信任私有仓库的证书。

lzz的博客 2143

判断URL图片是否存在

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ var im

kunkuny的专栏 1033

自动化上位机开发C#100例:如何用面向对象的方式封装雷赛运动控制卡EtherCAT总线卡(C#代码)

自动化上位机开发C#100例:雷赛运动控制卡EtherCAT总线卡C#封装类。

十多年IT经验,专注机器视觉,智能制造半导体行业 5035

YOLOv13保姆级教程+AKConv模块:可变形卷积+自适应核优化,mAP提升3.23%,召回率&mAP50~95显著提升(论文涨点模块已验证)

本文介绍了一种改进的YOLOv13-AKConv模型,通过引入AKConv模块显著提升了目标检测性能。实验结果表明,优化后的模型(绿色曲线)相比原模型(蓝色曲线)在mAP指标上提升了3.23个点,同时召回率、mAP50-95等指标均有明显提升。作者详细阐述了模型移植过程,包括创建yolov13-AKConv.yaml配置文件,修改tasks.py和modules/init.py文件,以及实现AKConv模块的核心代码。该模块采用可变形卷积思想,通过动态生成采样点位置来增强特征提取能力,并集成了BN和SiLU

FJN110的博客 2611

检测远程URL是否存在的三种方法(转孟子E章)

本文用3种方法检测远程URL是否存在。 Code privatevoidPage_Load(objectsender,System.EventArgse) { stringurl1="http://dotnet.aspx.cc/"; stringurl2="http://dotnet.aspx.cc/Images/logo.gif"; ...

dbul13262的博客 1265

【一看就会】Autoware.universe的“规划”部分源码梳理【0】——Planning综述(持续更新中)

单独开一篇planning综述,作为整个规划系列的开篇。本篇综述会持续更新,希望能帮助大家更好的整体理解规划部分。这个部分会持续更新。

weixin_48386130的博客 1967

[导入]检测远程URL是否存在的三种方法

检测远程URL是否存在的三种方法,本文用3种方法检测远程URL是否存在。文章来源:http://blog.csdn.net/net_lover/archive/2005/11/30/540417.aspx

weixin_34388207的博客 145

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

检测远程URL是否存在的三种方法<转>

检测远程URL是否存在的三种方法 来源:孟子E章 关键词:URL 存在 private void Page_Load(object sender, System.EventArgs e) { string url1 = "http://dotnet.aspx.cc/"; string url2 = "http://dotnet.aspx.cc/Images/...

weixin_33709590的博客 140

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

检测远程URL是否存在的三种方法[转载自孟子E章]

本文用3种方法检测远程URL是否存在。 private void Page_Load(object sender, System.EventArgs e){ string url1 = "http://dotnet.aspx.cc/";string url2 = "http://dotnet.aspx.cc/Images/logo.gif";Response.Write("<li&...

weixin_33958366的博客 74

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

上一篇: J2ME开发环境的安装和使用
下一篇: 在J2ME中实现图片的反转效果(包括垂直和水平)
java2000_test
博客等级 码龄19年 10粉丝 320原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值