JsHttpClient 1.0.6

HttpClient extension class, and the .Net Core version of the HttpHelper class.
Simple and flexible crawler base class library.
JsHttpClient类是 .Net Core 下的一个简单灵活的爬虫基础类库

Install-Package JsHttpClient -Version 1.0.6
dotnet add package JsHttpClient --version 1.0.6
<PackageReference Include="JsHttpClient" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JsHttpClient --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JsHttpClient, 1.0.6"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install JsHttpClient as a Cake Addin
#addin nuget:?package=JsHttpClient&version=1.0.6

// Install JsHttpClient as a Cake Tool
#tool nuget:?package=JsHttpClient&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Project Icon JsHttpClient

NuGet

JsHttpClient is a simple and flexible HTML page crawling client library for .Net Core

JsHttpClient 是一个用于在 .Net Core 上简单灵活的 HTML 页面抓取客户端库

Installation

JsHttpClient is available on NuGet.

Either open the package console and type:

PM> Install-Package JsHttpClient

Or right-click your project → Manage NuGet Packages... → Online → search for JsHttpClient in the top right.

Quick Start

To start, Add JsHttpClient client services at ConfigureServices(IServiceCollection services) .

//Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    //Add JsHttpClient client services
    services.AddJsHttpClient();
            
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}

For Example

using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using JasonSoft.Net.JsHttpClient.Http;

namespace JsHttpClient.WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        private readonly IJsHttpClient _client;

        /// <summary>
        /// 实例化
        /// Add by Jason.Song(成长的小猪) on 2019/04/24
        /// </summary>
        /// <param name="client"></param>
        public TestController(IJsHttpClient client)
        {
            _client = client;
        }

        /// <summary>
        /// Asynchronous request test
        /// 异步请求测试
        /// Add by Jason.Song(成长的小猪) on 2019/04/24
        /// </summary>
        /// <returns></returns>
        [HttpGet("HttpAsync")]
        public async Task<IActionResult> HttpAsync()
        {
            const string urlString = "https://blog.csdn.net/jasonsong2008";
            var request = new JsHttpRequest {Uri = urlString};
            //request.Method = HttpMethod.Get;
            //request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*";
            //request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36";
            //request.Referer = "https://blog.csdn.net/";
            //request.Host = "blog.csdn.net";
            //request.Cookie = "";
            //request.Timeout = 30;
            //request.Add("Upgrade-Insecure-Requests", "1");

            var result = await _client.SendAsync(request);
            return Content(result.Html, "text/html; charset=utf-8");
        }

        /// <summary>
        /// Synchronous request test
        /// 同步请求测试
        /// Add by Jason.Song(成长的小猪) on 2019/04/24
        /// </summary>
        /// <returns></returns>
        [HttpGet("HttpSync")]
        public IActionResult HttpSync()
        {
            const string urlString = "https://blog.csdn.net/jasonsong2008";
            var request = new JsHttpRequest {Uri = urlString};
            //request.Method = HttpMethod.Get;
            //request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*";
            //request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36";
            //request.Referer = "https://blog.csdn.net/";
            //request.Host = "blog.csdn.net";
            //request.Cookie = "";
            //request.Timeout = 30;
            //request.Add("Upgrade-Insecure-Requests", "1");

            var result = _client.Send(request);
            return Content(result.Html, "text/html; charset=utf-8");
        }
    }
}

Project Icon JsHttpClient

NuGet

JsHttpClient is a simple and flexible HTML page crawling client library for .Net Core

JsHttpClient 是一个用于在 .Net Core 上简单灵活的 HTML 页面抓取客户端库

Installation

JsHttpClient is available on NuGet.

Either open the package console and type:

PM> Install-Package JsHttpClient

Or right-click your project → Manage NuGet Packages... → Online → search for JsHttpClient in the top right.

Quick Start

To start, Add JsHttpClient client services at ConfigureServices(IServiceCollection services) .

//Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    //Add JsHttpClient client services
    services.AddJsHttpClient();
            
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}

For Example

using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using JasonSoft.Net.JsHttpClient.Http;

namespace JsHttpClient.WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        private readonly IJsHttpClient _client;

        /// <summary>
        /// 实例化
        /// Add by Jason.Song(成长的小猪) on 2019/04/24
        /// </summary>
        /// <param name="client"></param>
        public TestController(IJsHttpClient client)
        {
            _client = client;
        }

        /// <summary>
        /// Asynchronous request test
        /// 异步请求测试
        /// Add by Jason.Song(成长的小猪) on 2019/04/24
        /// </summary>
        /// <returns></returns>
        [HttpGet("HttpAsync")]
        public async Task<IActionResult> HttpAsync()
        {
            const string urlString = "https://blog.csdn.net/jasonsong2008";
            var request = new JsHttpRequest {Uri = urlString};
            //request.Method = HttpMethod.Get;
            //request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*";
            //request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36";
            //request.Referer = "https://blog.csdn.net/";
            //request.Host = "blog.csdn.net";
            //request.Cookie = "";
            //request.Timeout = 30;
            //request.Add("Upgrade-Insecure-Requests", "1");

            var result = await _client.SendAsync(request);
            return Content(result.Html, "text/html; charset=utf-8");
        }

        /// <summary>
        /// Synchronous request test
        /// 同步请求测试
        /// Add by Jason.Song(成长的小猪) on 2019/04/24
        /// </summary>
        /// <returns></returns>
        [HttpGet("HttpSync")]
        public IActionResult HttpSync()
        {
            const string urlString = "https://blog.csdn.net/jasonsong2008";
            var request = new JsHttpRequest {Uri = urlString};
            //request.Method = HttpMethod.Get;
            //request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*";
            //request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36";
            //request.Referer = "https://blog.csdn.net/";
            //request.Host = "blog.csdn.net";
            //request.Cookie = "";
            //request.Timeout = 30;
            //request.Add("Upgrade-Insecure-Requests", "1");

            var result = _client.Send(request);
            return Content(result.Html, "text/html; charset=utf-8");
        }
    }
}

Release Notes

const string urlString = "https://blog.csdn.net/jasonsong2008";
var request = new JsHttpRequest {Uri = urlString};
//request.Method = HttpMethod.Get;
//request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*";
//request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36";
//request.Referer = "https://blog.csdn.net/";
//request.Host = "blog.csdn.net";
//request.Cookie = "";
//request.Timeout = 30;
//request.Add("Upgrade-Insecure-Requests", "1");

var result = await _client.SendAsync(request);
return Content(result.Html, "text/html; charset=utf-8");

NuGet packages (1)

Showing the top 1 NuGet packages that depend on JsHttpClient:

Package Downloads
RG3.PF.Abstractions
1、【RG3.PF.Abstractions】(可配置化,标准化,灵活配置,集成百度、腾讯、阿里、短信通等巨头接口,可脱离开发环境,集成nodejs中间件、统一认证中心) 2、以Rg3.开头且类继承 IService 或 IRepository的在Starup里面不用注入,案例如下 3、public class ListRepository : IRepository 4、public class ListService : IService 5、使用请到github获取 RG3.PF.WebApp.Host 6、IDebugProvider改为异步写入集成redis订阅、Quartz

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.6 2,557 6/21/2020
1.0.5 454 8/1/2019
1.0.4 338 4/24/2019
1.0.3 340 4/24/2019
1.0.2 335 4/24/2019
1.0.1 342 4/24/2019
1.0.0 346 4/23/2019