2using System.Collections.Generic;
7using System.Threading.Tasks;
9using Newtonsoft.Json.Linq;
19 private string filePath;
25 public List<string> doTest()
29 List<string> listToRet =
new List<string>();
44 var jsonText = File.ReadAllText(filePath);
48 Newtonsoft.Json.JsonSerializer json =
new Newtonsoft.Json.JsonSerializer();
50 json.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
51 json.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace;
52 json.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
53 json.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
55 StringReader sr =
new StringReader(jsonText);
57 Newtonsoft.Json.JsonTextReader reader =
new JsonTextReader(sr);
58 var result = json.Deserialize<List<JObject>>(reader);
59 var ts = result.Values(
"test");
60 var ret = result.Values(
"ret").GetEnumerator() ;
63 foreach (var test
in ts)
66 Header h =
new Header() { SecChUa = test.Value<
string>(
"Sec-Ch-Ua"),
67 SecChUaFullVersion = test.Value<
string>(
"Sec-Ch-Ua-Full-Version"),
68 SecChUaFullVersionList = test.Value<
string>(
"Sec-Ch-Ua-Full-Version-List"),
69 SecChUaMobile = test.Value<
string>(
"Sec-Ch-Ua-Mobile"),
70 SecChUaModel = test.Value<
string>(
"Sec-Ch-Ua-Model"),
71 SecChUaPlatform = test.Value<
string>(
"Sec-Ch-Ua-Platform"),
72 SecChUaPlatformVersion = test.Value<
string>(
"Sec-Ch-Ua-Platform-Version"),
73 Ua = test.Value<
string>(
"User-Agent")
77 parser.ua = test.Value<
string>(
"User-Agent");
89 CrawlerCategory = r.Value<
string>(
"crawler_category"),
90 CrawlerCategoryCode = r.Value<
string>(
"crawler_category_code"),
91 CrawlerLastSeen =
null,
92 CrawlerRespectRobotstxt = r.Value<
string>(
"crawler_respect_robotstxt"),
93 DeviceBrand = r.Value<
string>(
"device_brand"),
94 DeviceBrandCode = r.Value<
string>(
"device_brand_code"),
95 DeviceBrandHomepage = r.Value<
string>(
"device_brand_homepage"),
96 DeviceBrandIcon = r.Value<
string>(
"device_brand_icon"),
97 DeviceBrandIconBig = r.Value<
string>(
"device_brand_icon_big"),
98 DeviceBrandInfoUrl = r.Value<
string>(
"device_brand_info_url"),
99 DeviceClass = r.Value<
string>(
"device_class"),
100 DeviceClassCode = r.Value<
string>(
"device_class_code"),
101 DeviceClassIcon = r.Value<
string>(
"device_class_icon"),
102 DeviceClassIconBig = r.Value<
string>(
"device_class_icon_big"),
103 DeviceClassInfoUrl = r.Value<
string>(
"device_class_info_url"),
104 DeviceMarketname = r.Value<
string>(
"device_marketname"),
105 Os = r.Value<
string>(
"os"),
106 OsCode = r.Value<
string>(
"os_code"),
107 OsFamily = r.Value<
string>(
"os_family"),
108 OsFamilyCode = r.Value<
string>(
"os_family_code"),
109 OsFamilyVendor = r.Value<
string>(
"os_family_vendor"),
110 OsFamilyVendorCode = r.Value<
string>(
"os_family_vendor_code"),
111 OsFamilyVendorHomepage = r.Value<
string>(
"os_family_vendor_homepage"),
112 OsHomepage = r.Value<
string>(
"os_homepage"),
113 OsIcon = r.Value<
string>(
"os_icon"),
114 OsIconBig = r.Value<
string>(
"os_icon_big"),
115 OsInfoUrl = r.Value<
string>(
"os_info_url"),
116 SecChUa = r.Value<
string>(
"sec_ch_ua"),
117 SecChUaFullVersion = r.Value<
string>(
"sec_ch_ua_full_version"),
118 SecChUaFullVersionList = r.Value<
string>(
"sec_ch_ua_full_version_list"),
119 SecChUaMobile = r.Value<
string>(
"sec_ch_ua_mobile"),
120 SecChUaModel = r.Value<
string>(
"sec_ch_ua_model"),
121 SecChUaPlatform = r.Value<
string>(
"sec_ch_ua_platform"),
122 SecChUaPlatformVersion = r.Value<
string>(
"sec_ch_ua_platform_version"),
123 Ua = r.Value<
string>(
"ua"),
124 UaClass = r.Value<
string>(
"ua_class"),
125 UaClassCode = r.Value<
string>(
"ua_class_code"),
126 UaEngine = r.Value<
string>(
"ua_engine"),
127 UaFamily = r.Value<
string>(
"ua_family"),
128 UaFamilyCode = r.Value<
string>(
"ua_family_code"),
129 UaFamilyHompage = r.Value<
string>(
"ua_family_homepage"),
130 UaFamilyIcon = r.Value<
string>(
"ua_family_icon"),
131 UaFamilyIconBig = r.Value<
string>(
"ua_family_icon_big"),
132 UaFamilyInfoUrl = r.Value<
string>(
"ua_family_info_url"),
133 UaFamilyVendor = r.Value<
string>(
"ua_family_vendor"),
134 UaFamilyVendorCode = r.Value<
string>(
"ua_family_vendor_code"),
135 UaFamilyVendorHomepage = r.Value<
string>(
"ua_family_vendor_homepage"),
136 UaString = r.Value<
string>(
"ua_string"),
137 UaUptodateCurrentVersion = r.Value<
string>(
"ua_uptodate_current_version"),
138 UaVersion = r.Value<
string>(
"ua_version"),
139 UaVersionMajor = r.Value<
string>(
"ua_version_major")
144 listToRet.Add($
"{count}{System.Environment.NewLine}{u.Compare(uToCompare)}");
void SetDataDir(string dataDir)
Set the data directory
void parse()
Parse the useragent string and/or ip address ///