如何屏蔽掉某网址不能访问

电脑上如何屏蔽掉某网址:

好处:屏蔽掉该网址后,浏览器就不能访问该网址了

在这里插入图片描述

具体过程:

打开 C:\Windows\System32\drivers\etc 文件夹,etc文件夹下有一个hosts文件,
选中hosts文件,鼠标右键,选择“属性 -> 安全 -> 组或用户名选 Users -> 编辑 -> 组或用户名选 Users -> 权限:完全控制打勾 ”应用 确定即可,

接着要设置需要屏蔽掉的网址了,用编辑器(如:记事本)打开hosts文件,

需求:假设我需要屏蔽掉 “4399”,这么设置即可:
格式:127.0.0.1 域名
例子:127.0.0.1 www.4399.com

保存即可。浏览器就不能访问该网址了。

在这里插入图片描述

声明:此文仅演示本文问题的解决方法,别无他意。

结束。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Java 中,可以使用 HttpURLConnection 或 HttpClient 来测试 https 网址是否能访问。下面分别介绍这两种方法的具体实现: 1. 使用 HttpURLConnection: ```java import java.net.HttpURLConnection; import java.net.URL; public class HttpsTester { public static void main(String[] args) { String httpsUrl = "https://example.com"; try { URL url = new URL(httpsUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.connect(); int code = conn.getResponseCode(); if (code == 200) { System.out.println(httpsUrl + " is available!"); } else { System.out.println(httpsUrl + " is not available!"); } } catch (Exception e) { System.out.println(httpsUrl + " is not available!"); } } } ``` 2. 使用 HttpClient: ```java import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.impl.client.HttpClients; public class HttpsTester { public static void main(String[] args) { String httpsUrl = "https://example.com"; try { HttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); HttpGet httpGet = new HttpGet(httpsUrl); HttpResponse response = httpClient.execute(httpGet); int code = response.getStatusLine().getStatusCode(); if (code == 200) { System.out.println(httpsUrl + " is available!"); } else { System.out.println(httpsUrl + " is not available!"); } } catch (Exception e) { System.out.println(httpsUrl + " is not available!"); } } } ``` 需要注意的是,在测试 https 网址时,需要考虑证书的验证问题。如果网站使用了自签名证书或者是不受信任的证书,那么需要在 HttpClient 中设置 NoopHostnameVerifier,才能正常访问

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值