Skip to content

Commit 54b82f5

Browse files
author
邹嵩
committed
修正Startup对.exe不扫描的问题
1 parent b06b712 commit 54b82f5

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

src/DotnetSpider.Core/DotnetSpider.Core.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFrameworks>net40;net45;netstandard2.0</TargetFrameworks>
44
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
55
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
6-
<Version>3.0.0</Version>
6+
<Version>3.0.1</Version>
77
<Authors>[email protected];</Authors>
88
<AssemblyName>DotnetSpider.Core</AssemblyName>
99
<Copyright>Copyright 2018 Lewis Zou</Copyright>

src/DotnetSpider.Core/Startup.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,18 @@ public static Dictionary<string, Type> DetectSpiders()
247247
public static List<string> DetectDlls()
248248
{
249249
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
250-
return Directory.GetFiles(path).Where(f => f.EndsWith(".dll")).Select(f => Path.GetFileName(f).Replace(".dll", "")).Where(f => !f.EndsWith("DotnetSpider.HtmlAgilityPack.Css") && !f.EndsWith("DotnetSpider.Extension") && !f.EndsWith("DotnetSpider2.Extension") && !f.EndsWith("DotnetSpider.Core") && !f.EndsWith("DotnetSpider2.Core") && DetectNames.Any(n => f.ToLower().Contains(n))).ToList();
250+
var files = Directory.GetFiles(path)
251+
.Where(f => f.EndsWith(".dll") || f.EndsWith(".exe"))
252+
.Select(f => Path.GetFileName(f).Replace(".dll", "").Replace(".exe", "")).ToList();
253+
return
254+
files.Where(f => !f.EndsWith("DotnetSpider.HtmlAgilityPack.Css")
255+
&& !f.EndsWith("DotnetSpider.Common")
256+
&& !f.EndsWith("DotnetSpider.Proxy")
257+
&& !f.EndsWith("DotnetSpider.Downloader")
258+
&& !f.EndsWith("DotnetSpider.Extraction")
259+
&& !f.EndsWith("DotnetSpider.Extension")
260+
&& !f.EndsWith("DotnetSpider.Core")
261+
&& DetectNames.Any(n => f.ToLower().Contains(n))).ToList();
251262
}
252263

253264
/// <summary>

src/DotnetSpider.Sample/Program.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading;
1+
using DotnetSpider.Core;
2+
using System.Threading;
23

34
namespace DotnetSpider.Sample
45
{
@@ -11,10 +12,7 @@ static void Main(string[] args)
1112
#else
1213
ThreadPool.SetMinThreads(256, 256);
1314
#endif
14-
TestSpider spider = new TestSpider();
15-
spider.Run();
16-
17-
15+
Startup.Run(args);
1816
}
1917

2018
/// <summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"profiles": {
3+
"DotnetSpider.Sample": {
4+
"commandName": "Project",
5+
"commandLineArgs": "-s:TestSpider -c:app.config --tid:fea52169bc754231a840767c6a30341f -i:92dcf0251f594f77a17f036f503a5493"
6+
}
7+
}
8+
}

src/DotnetSpider.Sample/TestSpider.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected override void OnInit(params string[] arguments)
2121
var word = "可乐|雪碧";
2222
AddStartUrl(string.Format("http://news.baidu.com/ns?word={0}&tn=news&from=news&cl=2&pn=0&rn=20&ct=1", word), new Dictionary<string, dynamic> { { "Keyword", word } });
2323
AddEntityType<BaiduSearchEntry>();
24-
AddPipeline(new SqlServerEntityPipeline("Server=.\\SQLEXPRESS;Database=master;Trusted_Connection=True;MultipleActiveResultSets=true"));
24+
AddPipeline(new MySqlEntityPipeline("Database='mysql';Data Source=localhost;User ID=root;Port=3306;SslMode=None;"));
2525
}
2626

2727
[TableInfo("baidu", "baidu_search_entity_model")]
@@ -43,16 +43,16 @@ class BaiduSearchEntry : BaseEntity
4343
[ReplaceFormatter(NewValue = "-", OldValue = "&nbsp;")]
4444
public string Website { get; set; }
4545

46-
[FieldSelector(Expression = ".//div/span/a[@class='c-cache']/@href", Length = 0)]
46+
[FieldSelector(Expression = ".//div/span/a[@class='c-cache']/@href")]
4747
public string Snapshot { get; set; }
4848

49-
[FieldSelector(Expression = ".//div[@class='c-summary c-row ']", Option = FieldOptions.InnerText, Length = 0)]
49+
[FieldSelector(Expression = ".//div[@class='c-summary c-row ']", Option = FieldOptions.InnerText)]
5050
[ReplaceFormatter(NewValue = "", OldValue = "<em>")]
5151
[ReplaceFormatter(NewValue = "", OldValue = "</em>")]
5252
[ReplaceFormatter(NewValue = " ", OldValue = "&nbsp;")]
5353
public string Details { get; set; }
5454

55-
[FieldSelector(Expression = ".", Option = FieldOptions.InnerText, Length = 0)]
55+
[FieldSelector(Expression = ".", Option = FieldOptions.InnerText)]
5656
[ReplaceFormatter(NewValue = "", OldValue = "<em>")]
5757
[ReplaceFormatter(NewValue = "", OldValue = "</em>")]
5858
[ReplaceFormatter(NewValue = " ", OldValue = "&nbsp;")]

src/DotnetSpider.Sample/app.config

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<connectionStrings>
4-
<add name="DataConnection" connectionString="Database='mysql';Data Source=localhost;User ID=root;Port=3306;SslMode=None;"
5-
providerName="MySql.Data.MySqlClient" />
4+
<add name="DataConnection" connectionString="Database='mysql';Data Source=localhost;password=;User ID=root;Port=3306;SslMode=None" providerName="MySql.Data.MySqlClient" />
65
</connectionStrings>
76
<appSettings>
8-
<add key="redisConnectString" value=""/>
9-
<add key="emailHost" value=""/>
10-
<add key="emailPort" value=""/>
11-
<add key="emailAccount" value=""/>
12-
<add key="emailPassword" value=""/>
13-
<add key="emailDisplayName" value=""/>
14-
<!--<add key="hub" value="http://localhost:30013/"/>
15-
<add key="hubToken" value="23D6BA4FE4C2485FA0471E2727E7EAA4"/>-->
7+
<add key="emailHost" value="" />
8+
<add key="emailPort" value="25" />
9+
<add key="emailAccount" value="" />
10+
<add key="emailPassword" value="" />
11+
<add key="emailDisplayName" value="Fintech Alert" />
12+
<!--<add key="hub" value="http://localhost:60001/"/>
13+
<add key="hubToken" value="7676B334FFB34354953FC04D691A60C3"/>-->
1614
</appSettings>
17-
</configuration>
15+
</configuration>

0 commit comments

Comments
 (0)