本文整理汇总了C#中IElement.QuerySelectorAll方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.QuerySelectorAll方法的具体用法?C# IElement.QuerySelectorAll怎么用?C# IElement.QuerySelectorAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.QuerySelectorAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReleaseInfo
private ReleaseInfo GetReleaseInfo(IElement row, IElement downloadAnchor, string title, int category)
{
// Parse required data
var downloadAnchorHref = downloadAnchor.Attributes["href"].Value;
var torrentId = downloadAnchorHref.Substring(downloadAnchorHref.LastIndexOf('=') + 1);
var qFiles = row.QuerySelector("td:nth-last-child(6)");
var files = ParseUtil.CoerceLong(qFiles.TextContent);
var publishDate = DateTime.ParseExact(row.QuerySelector(".time.tooltip").Attributes["title"].Value, "MMM dd yyyy, HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime();
var torrentData = row.QuerySelectorAll(".number_column"); // Size (xx.xx GB[ (Max)]) Snatches (xx) Seeders (xx) Leechers (xx)
if (torrentData.Length != 4)
throw new Exception($"We expected 4 torrent datas, instead we have {torrentData.Length}.");
if (torrentId.Contains('#'))
torrentId = torrentId.Split('#')[0];
var size = ReleaseInfo.GetBytes(torrentData[0].TextContent);
var grabs = int.Parse(torrentData[1].TextContent);
var seeders = int.Parse(torrentData[2].TextContent);
var guid = new Uri(GuidUrl + torrentId);
// Build releaseinfo
return new ReleaseInfo
{
Title = title,
Description = title,
Category = category, // Who seasons movies right
Link = new Uri(DownloadUrl + torrentId),
PublishDate = publishDate,
Seeders = seeders,
Peers = seeders,
Files = files,
Size = size,
Grabs = grabs,
Guid = guid,
Comments = guid,
DownloadVolumeFactor = 0, // ratioless tracker
UploadVolumeFactor = 1
};
}
示例2: Map
private static WebElement Map(IElement node)
{
if (node == null)
return null;
var el = new WebElement(value => node.SetAttribute("value", value))
{
Attributes = node.Attributes.ToDictionary(x => x.Name, y => y.Value),
TagName = node.TagName,
Text = node.TextContent,
InnerHtml = node.InnerHtml,
OuterHtml = node.OuterHtml
};
el.OnQuerySelector(query => Map(node.QuerySelector(query)));
el.OnQuerySelectorAll(query => node.QuerySelectorAll(query).Select(Map));
return el;
}
示例3: RemoveEmptyTags
private void RemoveEmptyTags(IElement rootElement)
{
foreach (IElement el in rootElement.QuerySelectorAll("div,span"))
{
if (string.IsNullOrWhiteSpace(el.TextContent) && el.ChildElementCount == 0)
{
el.Remove();
}
}
}
示例4: ExpandSpoilers
/// <summary>
/// Expands spoilers in HTML for easy reading.
/// Expects:
/// <div class="spoiler_header">Spoilerxxx</div>
/// <div class="spoiler_body" style="display: none;">xxxx</div>
/// </summary>
/// <param name="rootElement"></param>
protected void ExpandSpoilers(IElement rootElement)
{
foreach (IElement el in rootElement.QuerySelectorAll(".spoiler_body"))
{
el.SetAttribute("style", string.Empty);
el.SetAttribute("class", string.Empty);
}
foreach (IElement el in rootElement.QuerySelectorAll(".spoiler_header"))
{
el.Remove();
}
}
示例5: RemoveDonation
protected virtual void RemoveDonation(IElement rootElement)
{
foreach (var el in rootElement.QuerySelectorAll("div.thead"))
{
if (el.TextContent.Contains("Donation for the Author"))
el.Remove();
}
}
示例6: RemoveNavigation
protected virtual void RemoveNavigation(IElement rootElement)
{
// Last 1-2 tables might be navigation
foreach (var table in rootElement.QuerySelectorAll("table").Reverse().Take(2))
{
if (table.QuerySelectorAll("a").Any(x => x.TextContent.Contains("Chapter")))
{
table.Remove();
}
}
}