This repository was archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtext_extract.cs
More file actions
56 lines (35 loc) · 1.41 KB
/
text_extract.cs
File metadata and controls
56 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.IO;
using AlchemyAPI;
public class TestApp
{
static public void Main ()
{
// Create an AlchemyAPI object.
AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();
// Load an API key from disk.
alchemyObj.LoadAPIKey("api_key.txt");
// Extract page text from a web URL. (ignoring ads, navigation links, etc.)
string xml = alchemyObj.URLGetText("http://www.techcrunch.com/");
Console.WriteLine (xml);
// Extract raw page text from a web URL. (including ads, navigation links, etc.)
xml = alchemyObj.URLGetRawText("http://www.techcrunch.com/");
Console.WriteLine (xml);
// Extract a title from a web URL.
xml = alchemyObj.URLGetTitle("http://www.techcrunch.com/");
Console.WriteLine (xml);
// Load a HTML document to analyze.
StreamReader streamReader = new StreamReader("data/example.html");
string htmlDoc = streamReader.ReadToEnd();
streamReader.Close();
// Extract page text from a HTML document. (ignoring ads, navigation links, etc.)
xml = alchemyObj.HTMLGetText(htmlDoc, "http://www.test.com/");
Console.WriteLine (xml);
// Extract raw page text from a HTML document. (including ads, navigation links, etc.)
xml = alchemyObj.HTMLGetRawText(htmlDoc, "http://www.test.com/");
Console.WriteLine (xml);
// Extract a title from a HTML document.
xml = alchemyObj.HTMLGetTitle(htmlDoc, "http://www.test.com/");
Console.WriteLine (xml);
}
}