├── .gitignore
└── SpiderMan
├── SpiderMan.sln
├── Weibo
├── App.config
├── CatchByApiService.cs
├── Model
│ ├── WBBase.cs
│ ├── WBContainer.cs
│ └── WBPage.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Weibo.csproj
└── packages.config
└── packages
└── Newtonsoft.Json.12.0.3
├── .signature.p7s
├── LICENSE.md
├── Newtonsoft.Json.12.0.3.nupkg
├── lib
├── net20
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
├── net35
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
├── net40
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
├── net45
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
├── netstandard1.0
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
├── netstandard1.3
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
├── netstandard2.0
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
├── portable-net40+sl5+win8+wp8+wpa81
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
└── portable-net45+win8+wp8+wpa81
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.xml
└── packageIcon.png
/.gitignore:
--------------------------------------------------------------------------------
1 | [Bb]in/
2 | [Oo]bj/
--------------------------------------------------------------------------------
/SpiderMan/SpiderMan.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.705
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Weibo", "Weibo\Weibo.csproj", "{9E96FF00-84B9-4ACA-855C-64A17EB58E61}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {9E96FF00-84B9-4ACA-855C-64A17EB58E61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9E96FF00-84B9-4ACA-855C-64A17EB58E61}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9E96FF00-84B9-4ACA-855C-64A17EB58E61}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9E96FF00-84B9-4ACA-855C-64A17EB58E61}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {7FB87E4A-F3FB-4930-A5D9-E6508A28D754}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/CatchByApiService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Net.Http;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Weibo
9 | {
10 | public class CatchByApiService
11 | {
12 | private static readonly HttpClient HttpClient;
13 | static CatchByApiService()
14 | {
15 | HttpClient = new HttpClient();
16 | }
17 |
18 | public void Set(Dictionary args)
19 | {
20 | foreach (var item in args)
21 | {
22 | HttpClient.DefaultRequestHeaders.Add(item.Key, item.Value);
23 | }
24 | }
25 |
26 | public async Task Get(string uri)
27 | {
28 | try
29 | {
30 | HttpResponseMessage response = await HttpClient.GetAsync(uri);
31 | response.EnsureSuccessStatusCode();
32 | string responseBody = await response.Content.ReadAsStringAsync();
33 | return responseBody;
34 | }
35 | catch (Exception ex)
36 | {
37 | throw;
38 | }
39 | }
40 |
41 | public async Task Get()
42 | {
43 |
44 | }
45 |
46 | public async Task Test()
47 | {
48 | List list = new List();
49 | list.Add(Get());
50 | list.Add(Get());
51 |
52 | Task.WaitAll(list.ToArray());
53 | }
54 |
55 | public async Task DownloadImg(string imgUrl, string path, string name)
56 | {
57 | if (!Directory.Exists(path))
58 | {
59 | Directory.CreateDirectory(path);
60 | }
61 | await Download(imgUrl, path, name);
62 | }
63 |
64 | public async Task DownloadImg(List imgUrlList, string path)
65 | {
66 | int index = 1;
67 | if (!Directory.Exists(path))
68 | {
69 | Directory.CreateDirectory(path);
70 | }
71 | foreach (var item in imgUrlList)
72 | {
73 | await Download(item, path, index.ToString());
74 | index++;
75 | //if (index % 10 == 0)
76 | //{
77 | // await Task.Delay(1000);
78 | //}
79 | }
80 | }
81 |
82 | private async Task Download(string url, string path, string name, string type = "jpg")
83 | {
84 | using (var res = await HttpClient.GetAsync(url))
85 | {
86 | res.EnsureSuccessStatusCode();
87 | using (var reader = await res.Content.ReadAsStreamAsync())
88 | using (FileStream writer = new FileStream($"{path}/{name}.{type}", FileMode.OpenOrCreate, FileAccess.Write))
89 | {
90 | byte[] buff = new byte[512];
91 | int c = 0;
92 | while ((c = reader.Read(buff, 0, buff.Length)) > 0)
93 | {
94 | writer.Write(buff, 0, c);
95 | }
96 | }
97 | }
98 | }
99 |
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/Model/WBBase.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Weibo.Model
7 | {
8 | public class WBBase
9 | {
10 | [JsonProperty("ok")]
11 | public int Status { get; set; }
12 | [JsonProperty("data")]
13 | public T Data { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/Model/WBContainer.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Weibo.Model
7 | {
8 | public class WBContainer : WBBase
9 | {
10 | }
11 |
12 | public class WBContainerData
13 | {
14 | [JsonProperty("tabsInfo")]
15 | public TabsInfo TabsInfo { get; set; }
16 | }
17 |
18 | public class TabsInfo
19 | {
20 | [JsonProperty("tabs")]
21 | public Tab[] Tabs { get; set; }
22 | }
23 |
24 | public class Tab
25 | {
26 | [JsonProperty("tab_type")]
27 | public string TabType { get; set; }
28 |
29 | [JsonProperty("containerid")]
30 | public string Containerid { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/Model/WBPage.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Weibo.Model
7 | {
8 | public class WBPage: WBBase
9 | {
10 | }
11 |
12 | public class WBPageData
13 | {
14 | [JsonProperty("cardlistInfo")]
15 | public CardlistInfo CardlistInfo { get; set; }
16 | [JsonProperty("cards")]
17 | public Card[] Cards { get; set; }
18 | }
19 | public class CardlistInfo
20 | {
21 | [JsonProperty("total")]
22 | public int Total { get; set; }
23 | [JsonProperty("v_p")]
24 | public int V_p { get; set; }
25 | }
26 | public class Card
27 | {
28 | [JsonProperty("mblog")]
29 | public MBlog MBlog { get; set; }
30 | }
31 | public class MBlog
32 | {
33 | [JsonProperty("pics")]
34 | public Pic[] Pics { get; set; }
35 | [JsonProperty("user")]
36 | public User User { get; set; }
37 | }
38 | public class Pic
39 | {
40 | [JsonProperty("large")]
41 | public Large Large { get; set; }
42 | [JsonProperty("url")]
43 | public string Url { get; set; }
44 | }
45 | public class Large
46 | {
47 | [JsonProperty("url")]
48 | public string Url { get; set; }
49 | }
50 |
51 | public class User
52 | {
53 | [JsonProperty("screen_name")]
54 | public string UserName { get; set; }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/Program.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Weibo.Model;
8 |
9 | namespace Weibo
10 | {
11 | class Program
12 | {
13 | static string uid = string.Empty;
14 |
15 | static void Main(string[] args)
16 | {
17 | Task.Run(async () =>
18 | {
19 | Console.WriteLine("请输入用户Id:");
20 | uid = Console.ReadLine();
21 | uid = uid.Trim();
22 | Console.WriteLine("下载开始:");
23 | await Run();
24 | }).Wait();
25 |
26 | Console.WriteLine("下载结束,按任意键退出");
27 | Console.Read();
28 | }
29 |
30 | public static async Task Run()
31 | {
32 | CatchByApiService client = new CatchByApiService();
33 | //
34 | string url1 = $"https://m.weibo.cn/api/container/getIndex?type=uid&value={uid}";
35 | string tabres = await client.Get(url1);
36 | var tab = JsonConvert.DeserializeObject(tabres);
37 | string containerId = string.Empty;
38 | foreach (var item in tab.Data.TabsInfo.Tabs)
39 | {
40 | if (item.TabType == "weibo")
41 | {
42 | containerId = item.Containerid;
43 | break;
44 | }
45 | }
46 |
47 | //用来获取基础数据 包括: 微博总条数 用户名称
48 | string url2 = $"https://m.weibo.cn/api/container/getIndex?type=uid&value={uid}&containerid={containerId}&page=1";
49 | string cardres = await client.Get(url2);
50 | var cards = JsonConvert.DeserializeObject(cardres);
51 |
52 | int total = cards.Data.CardlistInfo.Total;
53 | //cards中MBlog可能为空
54 | string username = cards.Data.Cards.Where(e => e.MBlog != null && e.MBlog.User != null && e.MBlog.User.UserName != null)
55 | .FirstOrDefault().MBlog.User.UserName;
56 | int pages = total % 10 != 0 ? (total / 10 + 1) : (total / 10);
57 |
58 | for (int i = 1; i <= pages; i++)
59 | {
60 | await Load(uid, containerId, i, client, username);
61 | Console.WriteLine($"下载进度----- {i}/{pages}");
62 | }
63 | }
64 |
65 | public static async Task Load(string uid, string containerId, int pageIdnex, CatchByApiService client, string username)
66 | {
67 | //用来获取基础数据 包括: 微博总条数 用户名称
68 | string url2 = $"https://m.weibo.cn/api/container/getIndex?type=uid&value={uid}&containerid={containerId}&page={pageIdnex}";
69 | string cardres = await client.Get(url2);
70 | var cards = JsonConvert.DeserializeObject(cardres);
71 | var imgUrls = new List();
72 | if (cards.Data.Cards == null || cards.Data.Cards.Length == 0)
73 | {
74 | Console.WriteLine("用户数据不存在");
75 | }
76 | else
77 | {
78 | foreach (var card in cards.Data.Cards)
79 | {
80 | try
81 | {
82 | var list = card?.MBlog?.Pics?.Where(e => e.Large != null)?.Select(e => e.Large.Url);
83 | if (list != null)
84 | {
85 | imgUrls.AddRange(list);
86 | }
87 | }
88 | catch (Exception ex)
89 | {
90 | throw;
91 | }
92 | }
93 | }
94 | var root = System.Environment.CurrentDirectory;
95 | await client.DownloadImg(imgUrls, $"{root}//{username}//{pageIdnex}");
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Weibo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Weibo")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("9e96ff00-84b9-4aca-855c-64a17eb58e61")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/Weibo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9E96FF00-84B9-4ACA-855C-64A17EB58E61}
8 | Exe
9 | Weibo
10 | Weibo
11 | v4.6.1
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/SpiderMan/Weibo/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/.signature.p7s:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/.signature.p7s
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2007 James Newton-King
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/Newtonsoft.Json.12.0.3.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/Newtonsoft.Json.12.0.3.nupkg
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/netstandard1.3/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/netstandard1.3/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/SpiderMan/packages/Newtonsoft.Json.12.0.3/packageIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaxrunboo/SpiderMan/ff8b448d5308561b830c4eb1b6ef12f7fad41378/SpiderMan/packages/Newtonsoft.Json.12.0.3/packageIcon.png
--------------------------------------------------------------------------------