JsHttpClient 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package JsHttpClient --version 1.0.5                
NuGet\Install-Package JsHttpClient -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JsHttpClient" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JsHttpClient --version 1.0.5                
#r "nuget: JsHttpClient, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.5

// Install JsHttpClient as a Cake Tool
#tool nuget:?package=JsHttpClient&version=1.0.5                

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");
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 is compatible.  netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 7、添加时间戳 Convert.ToInt64(DateTimePFUtil.ToTimestampSecond(this.Expires)); 6、6.0.0.77开始,nodeserice迁移到RG3.PF.PinYinScriptEngineCliWrap

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 116,768 6/21/2020
1.0.5 840 8/1/2019
1.0.4 627 4/24/2019
1.0.3 643 4/24/2019
1.0.2 646 4/24/2019
1.0.1 631 4/24/2019
1.0.0 626 4/23/2019

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");