-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,72 @@ | ||
using HtmlAgilityPack; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using TrueLove.Lib.Models.Code; | ||
using Windows.UI.Xaml.Media.Imaging; | ||
|
||
namespace TrueLove.UWP.Spider | ||
{ | ||
public class RefineData | ||
{ | ||
public RefineData() | ||
public ObservableCollection<CommentItem> UpdateComment(string src) | ||
{ | ||
|
||
} | ||
public List<CommentItem> RefineComment(string src) | ||
{ | ||
var htmlDocument = new HtmlDocument(); | ||
htmlDocument.LoadHtml(src); | ||
List<CommentItem> currentList = new List<CommentItem>(); | ||
for (int i = 1; i <= 99; i++) | ||
var currentList = new ObservableCollection<CommentItem>(); | ||
try | ||
{ | ||
string namePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[1]/span"; | ||
string comPath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[2]"; | ||
string datePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[3]"; | ||
var htmlDocument = new HtmlDocument(); | ||
htmlDocument.LoadHtml(src); | ||
for (int i = 1; i <= 96; i++) | ||
{ | ||
string namePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[1]/span"; | ||
string comPath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[2]"; | ||
string datePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[3]"; | ||
|
||
var nameText = htmlDocument.DocumentNode.SelectSingleNode(namePath).InnerText; | ||
var comText = htmlDocument.DocumentNode.SelectSingleNode(comPath).InnerText; | ||
var dateText = htmlDocument.DocumentNode.SelectSingleNode(datePath).InnerText; | ||
var parsedDate = DateTime.Parse(dateText); | ||
var nameText = htmlDocument.DocumentNode.SelectSingleNode(namePath).InnerText; | ||
var comText = htmlDocument.DocumentNode.SelectSingleNode(comPath).InnerText; | ||
var dateText = htmlDocument.DocumentNode.SelectSingleNode(datePath).InnerText; | ||
var parsedDate = DateTime.Parse(dateText); | ||
|
||
if (new[] { nameText, comText, dateText } != null) | ||
{ | ||
currentList.Add(new CommentItem | ||
if (new[] { nameText, comText, dateText } != null) | ||
{ | ||
name = nameText, | ||
comment = comText, | ||
date = parsedDate.ToString("d"), | ||
}); | ||
currentList.Add(new CommentItem | ||
{ | ||
name = nameText, | ||
comment = comText, | ||
date = parsedDate.ToString("d"), | ||
}); | ||
} | ||
} | ||
return currentList; | ||
} | ||
catch (NullReferenceException) | ||
{ | ||
return currentList; | ||
} | ||
return currentList; | ||
} | ||
public List<BitmapImage> RefineImage(string src) | ||
public ObservableCollection<BitmapImage> UpdateImage(string src) | ||
{ | ||
var htmlDocument = new HtmlDocument(); | ||
htmlDocument.LoadHtml(src); | ||
List<BitmapImage> currentList = new List<BitmapImage>(); | ||
for (int i = 1; i <= 50; i++) | ||
var currentList = new ObservableCollection<BitmapImage>(); | ||
try | ||
{ | ||
string imagePath = $"//*[@id=\"instagramhashtag\"]/ul/li[{i}]/img"; | ||
var htmlDocument = new HtmlDocument(); | ||
htmlDocument.LoadHtml(src); | ||
|
||
var imageNode = htmlDocument.DocumentNode.SelectSingleNode(imagePath); | ||
if (imageNode != null) | ||
for (int i = 1; i <= 50; i++) | ||
{ | ||
currentList.Add(new BitmapImage(new Uri("https://avicii.com" + imageNode.Attributes["src"].Value))); | ||
string imagePath = $"//*[@id=\"instagramhashtag\"]/ul/li[{i}]/img"; | ||
|
||
var imageNode = htmlDocument.DocumentNode.SelectSingleNode(imagePath); | ||
if (imageNode != null) | ||
{ | ||
currentList.Add(new BitmapImage(new Uri("https://avicii.com" + imageNode.Attributes["src"].Value))); | ||
} | ||
} | ||
return currentList; | ||
} | ||
catch | ||
{ | ||
return currentList; | ||
} | ||
return currentList; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters