Skip to content

Instantly share code, notes, and snippets.

@gravityFlower
Created June 7, 2015 22:13
Show Gist options
  • Save gravityFlower/6e42f0c1f3f25306ebf6 to your computer and use it in GitHub Desktop.
Save gravityFlower/6e42f0c1f3f25306ebf6 to your computer and use it in GitHub Desktop.
Example for CSQuery to test possible error.
<!DOCTYPE html>
<html class="js no-touch svg inlinesvg svgclippaths no-ie8compat ng-scope" lang="en" ng-app="psModule" id="ng-app">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8" http-equiv="Content-type" content="text/html;">
<meta name="viewport" content="width=device-width">
<meta name="fragment" content="!">
<title>Page</title>
<base href=".">
</head>
<body>
<div class="clear-both ng-scope">
<div ng-show="transcripts.userIsAuthorizedForCourseTranscripts" ng-repeat="module in transcripts.modules" class="ng-scope">
<h4 class="ng-binding">Beginning ProductXY</h4>
<!-- ngRepeat: clip in module.clips -->
<div ng-repeat="clip in module.clips" class="ng-scope">
<h6 class="clipTitle"><a ng-click="openPlayer(clip.playerParameters)" class="ng-binding">Introduction</a></h6>
<p transcripts="" clip="clip" class="ng-isolate-scope"><a class="clipTranscript" >Hi. Welcome to Beginning ProductXY. </a></p>
<p></p>
</div>
<!-- end ngRepeat: clip in module.clips -->
<div ng-repeat="clip in module.clips" class="ng-scope">
<h6 class="clipTitle"><a ng-click="openPlayer(clip.playerParameters)" class="ng-binding">Basics of ProductXY</a></h6>
<p transcripts="" clip="clip" class="ng-isolate-scope"><a class="clipTranscript" >In the opening, I mentioned the old command line interface that's still built into various Windows products, such </a></p>
<p></p>
</div>
</div>
<div ng-show="transcripts.userIsAuthorizedForCourseTranscripts" ng-repeat="module in transcripts.modules" class="ng-scope">
<h4 class="ng-binding">ProductXY Variables</h4>
<!-- ngRepeat: clip in module.clips -->
<div ng-repeat="clip in module.clips" class="ng-scope">
<h6 class="clipTitle"><a ng-click="openPlayer(clip.playerParameters)" class="ng-binding">Introduction</a></h6>
<p transcripts="" clip="clip" class="ng-isolate-scope"><a class="clipTranscript" >Greetings. Welcome to Variables in ProductXY. </a></p>
<p></p>
</div>
<div ng-repeat="clip in module.clips" class="ng-scope">
<h6 class="clipTitle"><a ng-click="openPlayer(clip.playerParameters)" class="ng-binding">Cmdlets</a></h6>
<p transcripts="" clip="clip" class="ng-isolate-scope"><a class="clipTranscript" >In our lesson on variables so far, you seen variable usage that's pretty much like any other language. </a></p>
<p></p>
</div>
</div>
<div ng-show="transcripts.userIsAuthorizedForCourseTranscripts" ng-repeat="module in transcripts.modules" class="ng-scope">
<h4 class="ng-binding">ProductXY programming</h4>
<div ng-repeat="clip in module.clips" class="ng-scope">
<h6 class="clipTitle"><a ng-click="openPlayer(clip.playerParameters)" class="ng-binding">Introduction and Branching</a></h6>
<p transcripts="" clip="clip" class="ng-isolate-scope"><a class="clipTranscript" >In this video, we'll cover the Fundamentals of ProductXY Programming. </a></p>
<p></p>
</div>
<div ng-repeat="clip in module.clips" class="ng-scope">
<h6 class="clipTitle"><a ng-click="openPlayer(clip.playerParameters)" class="ng-binding">ProductXY Looping</a></h6>
<p transcripts="" clip="clip" class="ng-isolate-scope"><a class="clipTranscript" >Looping is another fundamental construct of most programming languages. </a></p>
<p></p>
</div>
</div>
</div>
</body>
</html>
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
var result = CQ.CreateFromFile("<Path to html file>");
var filtered = result["div[ng-show='transcripts.userIsAuthorizedForCourseTranscripts']"];
if (filtered != null)
{
filtered.Each(ExtractSubs);
}
}
static void ExtractSubs(int index, IDomObject element)
{
//since this Cq should act on element, there should be only one element
var dirName = element.Cq()["h4.ng-binding"];
var clips = element.Cq()["div[ng-repeat='clip in module.clips']"];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment