demo: 我就不上传了

前言

在实际生活中,网络请求的应用极其常见,比如使用浏览器,程序中我们还要调用webservice。那么浏览器是怎么请求网络资源的呢?不用它可以自己请求不?

答案是可以的。

如果我们可以用自己的程序主动发起网络请求,那么我们可以:模拟提交数据,做一些简单网页游戏的外挂,可以刷一些帖子的访问量,可以抓取网络上的资源……

废话不我说,此文以使用Get方式对有道词典网进行请求为核心,编写了一个简单的单词查询客户端。正则表达式不太懂可以改为字符串基本操作,或者对其自己做一下基本的了解和学习。

【注:致初学都系列,一般以简单有意义的demo为例,介绍某类知识点(此文已以黑体标出)。其中API不懂的可以留言讨论。如有兴趣可以查询MSDN进行深入学习(笔者所期望的)】

效果图:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXgAAADdCAIAAAA+Wf4YAAAYc0lEQVR4nO2de3QUVZ7H66/Vddcz7kzWGV3/8ORoxtecPRLceYmOtDJDFHCmdxrQgy+gUdAAAhkRDA6OokJCeGQNCREQiDw8PkGoJCQVEyE8BCqBBGJCEpKQUAJigrpnDfb+UUlX9b1dt251+nZXOt/P+Z6c6lu3fvd2uuuTW9XaSN/1M3z48JEjR8qy3NbWFgAAgIHR29v75dlz/+FJS7r2WilomeXLl7e3t+ftOIogCBKt1Fz8fmtdS59oRo4c2d7evmaHiiAIEt1UXPhW0pczsiyv2akiCIKISJ9o2tra8j+tQRAEEZE+0Xz//fcFu2oRBEFEpE80gUCgcPcxBEEQETFE87Z8DEEQREQM0awrrkMQBBERiAZBEOGBaJAEz4ptVc++vGbSzNdjk2dfXrNiW1Xch15fVDppxBhPUnJsMmnEmPVFpYxXwRDNhpJ6BEm8TM3IkSuPNnd1xyZy5dGpGTlxH3pcyl3F+QWXag/FJsX5BeNS7mK8CryiUSIi7m8yBHl81hvNXd2Vxzpjk+au7sdnvRH3oT1JyT3qgbNb18YmPeoBT1Iy41VwIBq6RVGU45uu16NuuE7dcN3BtT/fm3dt2cokiAZxSZ6Y/eapzu6K2s7Y5FRn9xOz34z70J6k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DgQDQBAOBANAEA4EA0AQDgQDQBAOBANAEA4EA0AQDgQDQBAOBANAEA4EA0AQDg2opFVDUEQREQgGgRBhAeiQRBEeCAaBEGEB6JBEER4IBoEQYQHokEQRHj6RHPLkXYEQRBB+X91nNWmIfqFzQAAAABJRU5ErkJggg==" alt="" />

代码:

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions; namespace NetCapture
{
/// <summary>
/// base类。以后我们可能写别的类似请求,通过继承此类,可以省下一些代码。
/// </summary>
public abstract class GetScraperBase
{
//正则表达式的匹配模式
protected abstract string Pattern { get; }
//如何过滤正则表达式匹配的结果
protected abstract Dictionary<string, string> FilterMatch(Match match);
//抓取网页上的内容
public Dictionary<string, string> Scrape(string url, WebProxy proxy = null)
{
var request = WebRequest.Create(url); //创建request
if (proxy != null)
{
request.Proxy = proxy;//可能你在一些环境上不了网,得使用代理服务器
}
var response = request.GetResponse(); //获取response
var stream = response.GetResponseStream();
var responseReader = new StreamReader(stream);
var content = responseReader.ReadToEnd(); //读取response(页面对应的html)
var match = Regex.Match(content, Pattern, RegexOptions.IgnorePatternWhitespace); //筛选内容
return FilterMatch(match);
}
} public class YouDaoScaper : GetScraperBase
{
protected override string Pattern
{
get
{
/* Target result in response:
<div class="trans-container">
<ul>
<li>n. 试验;检验</li>
<li>vt. 试验;测试</li>
<li>vi. 试验;测试</li>
<li>n. (Test)人名;(英)特斯特</li>
</ul>
*
* there are two groups in this pattern, first is '<li>(?<content>.+)</li>[\r\n\s]*'
* it's an unnamed group, it has four capture:
* first is '<li>n. 试验;检验</li>' and so on.
*
* another group is and named group 'content' , it has four capture, in this sampe:
* capture 1 is 'n. 试验;检验' and so on.
*/ return @"<div\sclass=""trans-container"">[\r\n\s]*
<ul>[\r\n\s]*
(<li>(?<content>.+)</li>[\r\n\s]*)*
</ul>";
}
} protected override Dictionary<string, string> FilterMatch(Match match)
{
var dict=new Dictionary<string, string>();
var content = "";
var group=match.Groups["content"];
if(group.Success)
{
foreach (Capture capture in group.Captures)
{
content += (capture.Value + "\n");
}
}
dict["content"]=content;
return dict;
} public string QueryWord(string word)
{
var url= "http://dict.youdao.com/search?q="+word;
var dict = Scrape(url);
return dict["content"];
}
}
}
 

[System.Net]模拟Web请求编写简易单词查询客户端的更多相关文章

  1. 经验总结20--C#模拟WEB请求

    非常多语言能够使用代码进行WEB请求,获取到须要的数据. 方便调用别人的接口,自己进行处理. HttpWebRequest request = WebRequest.Create(url) as Ht ...

  2. 模拟HTTP请求:Request Maker

    摘要 : Request Maker是一款可以模拟HTTP请求的谷歌浏览器插件. Request Maker的开发背景 现在由于restful式的web api的兴起,越来越多的开发者习惯使用URL来 ...

  3. C#模拟httpwebrequest请求_向服务器模拟cookie发送

    使用C#代码模拟web请求,是一种常用的方法,以前没专门整理过,这里暂时贴上自己整理的完整代码,以后再做梳理: public class MyRequest { #region 辅助方法 public ...

  4. js_html_input中autocomplete="off"在chrom中失效的解决办法 使用JS模拟锚点跳转 js如何获取url参数 C#模拟httpwebrequest请求_向服务器模拟cookie发送 实习期学到的技术(一) LinqPad的变量比较功能 ASP.NET EF 使用LinqPad 快速学习Linq

    js_html_input中autocomplete="off"在chrom中失效的解决办法 分享网上的2种办法: 1-可以在不需要默认填写的input框中设置 autocompl ...

  5. 使用 C# 编写简易 ASP.NET Web 服务器 ---- 模拟IIS的处理过程

    如果你想获得更好的阅读体验,可以前往我在 github 上的博客进行阅读,http://lcomplete.github.io/blog/2013/07/16/use-csharp-write-asp ...

  6. C# 编写简易 ASP.NET Web 服务器

    C# 编写简易 ASP.NET Web 服务器 你是否有过这样的需求——想运行 ASP.NET 程序,又不想安装 IIS 或者 Visual Studio?我想如果你经常编写 ASP.NET 程序的话 ...

  7. 使用 C# 编写简易 ASP.NET Web 服务器

    原文 http://www.cnblogs.com/lcomplete/p/use-csharp-write-aspnet-web-server.html 如果你想获得更好的阅读体验,可以前往我在 g ...

  8. 第三百二十七节,web爬虫讲解2—urllib库爬虫—基础使用—超时设置—自动模拟http请求

    第三百二十七节,web爬虫讲解2—urllib库爬虫 利用python系统自带的urllib库写简单爬虫 urlopen()获取一个URL的html源码read()读出html源码内容decode(& ...

  9. 模拟界面请求到web服务器

    客户端 package com.lsw.client; import java.io.*; import java.net.*; import java.util.*; public class HT ...

随机推荐

  1. POJ 2236 Wireless Network (并查集)

    Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 18066   Accepted: 761 ...

  2. Linux 字符设备驱动模型

    一.使用字符设备驱动程序 1. 编译/安装驱动 在Linux系统中,驱动程序通常采用内核模块的程序结构来进行编码.因此,编译/安装一个驱动程序,其实质就是编译/安装一个内核模块 2. 创建设备文件 通 ...

  3. macOS10.12允许所有来源设置

    如何调出允许所有来源呢? 很简单一行命令搞定 调出允许所有来源 1.打开终端执行命令 sudo spctl --master-disable 2.你在打开偏好设置--> 安全与隐私   好了赶快 ...

  4. 深入理解ThreadLocal(转)(2015年06月11日)

    注明:转自:http://my.oschina.net/clopopo/blog/149368 学习一个东西首先要知道为什么要引入它,就是我们能用它来干什么.所以我们先来看看ThreadLocal对我 ...

  5. Mybatis源码解析(一)(2015年06月11日)

    一.简介 先看看Mybatis的源码结构图,Mybatis3.2.7版本包含的包共计19个,其他版本可能会少. 每个基于 MyBatis 的应用都是以一个 SqlSessionFactory 的实例为 ...

  6. Backbone.js学习之View

    千呼万唤始出来,终于到最后一个要点View了.照旧,先来一睹官方文档: Backbone views are almost more convention than they are code - t ...

  7. Table of Contents - Git

    Downloading and  Installing Git Download for Linux and Unix Integration with Eclipse Eclipse 提交工程至 G ...

  8. ado模版不会自动生成

    从数据库中更新模版的时候,其他文件都更新了,只有tt文件下的cs文件是没有更新的,没有添加也没有修改,在网上找了很久都没有这方面的信息. 其实只要删掉,重建一个ado模版就好.根本就不需要纠结.最后还 ...

  9. 五.CSS盒子模型

    所谓盒模型,就是浏览器为每个HTML元素生成的矩形盒子.即HTML页面实际上就是由一系列盒子组成.这些盒子是按照可见版式在页面上排布的.并由三个属性进行控制:position属性,display属性, ...

  10. android自定义UI模板图文详解

    不知道大家在实际开发中有没有自定义过UI模板?今天花时间研究了一下android中自定义UI模板,与大家分享一下. 每个设计良好的App都是自定义标题栏,在自定义标题栏的过程中大部分人可能都是自定义一 ...