You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

911 lines
26 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>gofeed - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package gofeed</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "github.com/mmcdole/gofeed"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. <dd><a href="index.html#pkg-examples" class="examplesLink">Examples</a></dd>
  58. <dd><a href="index.html#pkg-subdirectories">Subdirectories</a></dd>
  59. </dl>
  60. </div>
  61. <!-- The package's Name is printed as title by the top-level template -->
  62. <div id="pkg-overview" class="toggleVisible">
  63. <div class="collapsed">
  64. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  65. </div>
  66. <div class="expanded">
  67. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  68. </div>
  69. </div>
  70. <div id="pkg-index" class="toggleVisible">
  71. <div class="collapsed">
  72. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  73. </div>
  74. <div class="expanded">
  75. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  76. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  77. <div id="manual-nav">
  78. <dl>
  79. <dd><a href="index.html#DefaultAtomTranslator">type DefaultAtomTranslator</a></dd>
  80. <dd>&nbsp; &nbsp; <a href="index.html#DefaultAtomTranslator.Translate">func (t *DefaultAtomTranslator) Translate(feed interface{}) (*Feed, error)</a></dd>
  81. <dd><a href="index.html#DefaultRSSTranslator">type DefaultRSSTranslator</a></dd>
  82. <dd>&nbsp; &nbsp; <a href="index.html#DefaultRSSTranslator.Translate">func (t *DefaultRSSTranslator) Translate(feed interface{}) (*Feed, error)</a></dd>
  83. <dd><a href="index.html#Enclosure">type Enclosure</a></dd>
  84. <dd><a href="index.html#Feed">type Feed</a></dd>
  85. <dd>&nbsp; &nbsp; <a href="index.html#Feed.String">func (f Feed) String() string</a></dd>
  86. <dd><a href="index.html#FeedType">type FeedType</a></dd>
  87. <dd>&nbsp; &nbsp; <a href="index.html#DetectFeedType">func DetectFeedType(feed io.Reader) FeedType</a></dd>
  88. <dd><a href="index.html#HTTPError">type HTTPError</a></dd>
  89. <dd>&nbsp; &nbsp; <a href="index.html#HTTPError.Error">func (err HTTPError) Error() string</a></dd>
  90. <dd><a href="index.html#Image">type Image</a></dd>
  91. <dd><a href="index.html#Item">type Item</a></dd>
  92. <dd><a href="index.html#Parser">type Parser</a></dd>
  93. <dd>&nbsp; &nbsp; <a href="index.html#NewParser">func NewParser() *Parser</a></dd>
  94. <dd>&nbsp; &nbsp; <a href="index.html#Parser.Parse">func (f *Parser) Parse(feed io.Reader) (*Feed, error)</a></dd>
  95. <dd>&nbsp; &nbsp; <a href="index.html#Parser.ParseString">func (f *Parser) ParseString(feed string) (*Feed, error)</a></dd>
  96. <dd>&nbsp; &nbsp; <a href="index.html#Parser.ParseURL">func (f *Parser) ParseURL(feedURL string) (feed *Feed, err error)</a></dd>
  97. <dd><a href="index.html#Person">type Person</a></dd>
  98. <dd><a href="index.html#Translator">type Translator</a></dd>
  99. </dl>
  100. </div><!-- #manual-nav -->
  101. <div id="pkg-examples">
  102. <h4>Examples</h4>
  103. <dl>
  104. <dd><a class="exampleLink" href="index.html#example_DetectFeedType">DetectFeedType</a></dd>
  105. <dd><a class="exampleLink" href="index.html#example_Parser_Parse">Parser.Parse</a></dd>
  106. <dd><a class="exampleLink" href="index.html#example_Parser_ParseString">Parser.ParseString</a></dd>
  107. <dd><a class="exampleLink" href="index.html#example_Parser_ParseURL">Parser.ParseURL</a></dd>
  108. </dl>
  109. </div>
  110. <h4>Package files</h4>
  111. <p>
  112. <span style="font-size:90%">
  113. <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/detector.go">detector.go</a>
  114. <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/feed.go">feed.go</a>
  115. <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go">parser.go</a>
  116. <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/translator.go">translator.go</a>
  117. </span>
  118. </p>
  119. </div><!-- .expanded -->
  120. </div><!-- #pkg-index -->
  121. <div id="pkg-callgraph" class="toggle" style="display: none">
  122. <div class="collapsed">
  123. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  124. </div> <!-- .expanded -->
  125. <div class="expanded">
  126. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  127. <p>
  128. In the call graph viewer below, each node
  129. is a function belonging to this package
  130. and its children are the functions it
  131. calls&mdash;perhaps dynamically.
  132. </p>
  133. <p>
  134. The root nodes are the entry points of the
  135. package: functions that may be called from
  136. outside the package.
  137. There may be non-exported or anonymous
  138. functions among them if they are called
  139. dynamically from another package.
  140. </p>
  141. <p>
  142. Click a node to visit that function's source code.
  143. From there you can visit its callers by
  144. clicking its declaring <code>func</code>
  145. token.
  146. </p>
  147. <p>
  148. Functions may be omitted if they were
  149. determined to be unreachable in the
  150. particular programs or tests that were
  151. analyzed.
  152. </p>
  153. <!-- Zero means show all package entry points. -->
  154. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  155. </div>
  156. </div> <!-- #pkg-callgraph -->
  157. <h2 id="DefaultAtomTranslator">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/translator.go?s=11953:11988#L403">DefaultAtomTranslator</a></h2>
  158. <pre>type DefaultAtomTranslator struct{}</pre>
  159. <p>
  160. DefaultAtomTranslator converts an atom.Feed struct
  161. into the generic Feed struct.
  162. </p>
  163. <p>
  164. This default implementation defines a set of
  165. mapping rules between atom.Feed -&gt; Feed
  166. for each of the fields in Feed.
  167. </p>
  168. <h3 id="DefaultAtomTranslator.Translate">func (*DefaultAtomTranslator) <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/translator.go?s=12058:12132#L407">Translate</a></h3>
  169. <pre>func (t *<a href="index.html#DefaultAtomTranslator">DefaultAtomTranslator</a>) Translate(feed interface{}) (*<a href="index.html#Feed">Feed</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  170. <p>
  171. Translate converts an Atom feed into the universal
  172. feed type.
  173. </p>
  174. <h2 id="DefaultRSSTranslator">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/translator.go?s=592:626#L16">DefaultRSSTranslator</a></h2>
  175. <pre>type DefaultRSSTranslator struct{}</pre>
  176. <p>
  177. DefaultRSSTranslator converts an rss.Feed struct
  178. into the generic Feed struct.
  179. </p>
  180. <p>
  181. This default implementation defines a set of
  182. mapping rules between rss.Feed -&gt; Feed
  183. for each of the fields in Feed.
  184. </p>
  185. <h3 id="DefaultRSSTranslator.Translate">func (*DefaultRSSTranslator) <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/translator.go?s=695:768#L20">Translate</a></h3>
  186. <pre>func (t *<a href="index.html#DefaultRSSTranslator">DefaultRSSTranslator</a>) Translate(feed interface{}) (*<a href="index.html#Feed">Feed</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  187. <p>
  188. Translate converts an RSS feed into the universal
  189. feed type.
  190. </p>
  191. <h2 id="Enclosure">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/feed.go?s=3003:3146#L66">Enclosure</a></h2>
  192. <pre>type Enclosure struct {
  193. URL <a href="../../../builtin/index.html#string">string</a> `json:&#34;url,omitempty&#34;`
  194. Length <a href="../../../builtin/index.html#string">string</a> `json:&#34;length,omitempty&#34;`
  195. Type <a href="../../../builtin/index.html#string">string</a> `json:&#34;type,omitempty&#34;`
  196. }</pre>
  197. <p>
  198. Enclosure is a file associated with a given Item.
  199. </p>
  200. <h2 id="Feed">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/feed.go?s=209:1403#L3">Feed</a></h2>
  201. <pre>type Feed struct {
  202. Title <a href="../../../builtin/index.html#string">string</a> `json:&#34;title,omitempty&#34;`
  203. Description <a href="../../../builtin/index.html#string">string</a> `json:&#34;description,omitempty&#34;`
  204. Link <a href="../../../builtin/index.html#string">string</a> `json:&#34;link,omitempty&#34;`
  205. FeedLink <a href="../../../builtin/index.html#string">string</a> `json:&#34;feedLink,omitempty&#34;`
  206. Updated <a href="../../../builtin/index.html#string">string</a> `json:&#34;updated,omitempty&#34;`
  207. UpdatedParsed *<a href="../../../time/index.html">time</a>.<a href="../../../time/index.html#Time">Time</a> `json:&#34;updatedParsed,omitempty&#34;`
  208. Published <a href="../../../builtin/index.html#string">string</a> `json:&#34;published,omitempty&#34;`
  209. PublishedParsed *<a href="../../../time/index.html">time</a>.<a href="../../../time/index.html#Time">Time</a> `json:&#34;publishedParsed,omitempty&#34;`
  210. Author *<a href="index.html#Person">Person</a> `json:&#34;author,omitempty&#34;`
  211. Language <a href="../../../builtin/index.html#string">string</a> `json:&#34;language,omitempty&#34;`
  212. Image *<a href="index.html#Image">Image</a> `json:&#34;image,omitempty&#34;`
  213. Copyright <a href="../../../builtin/index.html#string">string</a> `json:&#34;copyright,omitempty&#34;`
  214. Generator <a href="../../../builtin/index.html#string">string</a> `json:&#34;generator,omitempty&#34;`
  215. Categories []<a href="../../../builtin/index.html#string">string</a> `json:&#34;categories,omitempty&#34;`
  216. Extensions ext.<a href="index.html#Extensions">Extensions</a> `json:&#34;extensions,omitempty&#34;`
  217. Custom map[<a href="../../../builtin/index.html#string">string</a>]<a href="../../../builtin/index.html#string">string</a> `json:&#34;custom,omitempty&#34;`
  218. Items []*<a href="index.html#Item">Item</a> `json:&#34;items&#34;`
  219. FeedType <a href="../../../builtin/index.html#string">string</a> `json:&#34;feedType&#34;`
  220. FeedVersion <a href="../../../builtin/index.html#string">string</a> `json:&#34;feedVersion&#34;`
  221. }</pre>
  222. <p>
  223. Feed is the universal Feed type that atom.Feed
  224. and rss.Feed gets translated to. It represents
  225. a web feed.
  226. </p>
  227. <h3 id="Feed.String">func (Feed) <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/feed.go?s=1405:1434#L25">String</a></h3>
  228. <pre>func (f <a href="index.html#Feed">Feed</a>) String() <a href="../../../builtin/index.html#string">string</a></pre>
  229. <h2 id="FeedType">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/detector.go?s=196:213#L3">FeedType</a></h2>
  230. <pre>type FeedType <a href="../../../builtin/index.html#int">int</a></pre>
  231. <p>
  232. FeedType represents one of the possible feed
  233. types that we can detect.
  234. </p>
  235. <pre>const (
  236. <span class="comment">// FeedTypeUnknown represents a feed that could not have its</span>
  237. <span class="comment">// type determiend.</span>
  238. <span id="FeedTypeUnknown">FeedTypeUnknown</span> <a href="index.html#FeedType">FeedType</a> = <a href="../../../builtin/index.html#iota">iota</a>
  239. <span class="comment">// FeedTypeAtom repesents an Atom feed</span>
  240. <span id="FeedTypeAtom">FeedTypeAtom</span>
  241. <span class="comment">// FeedTypeRSS represents an RSS feed</span>
  242. <span id="FeedTypeRSS">FeedTypeRSS</span>
  243. )</pre>
  244. <h3 id="DetectFeedType">func <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/detector.go?s=582:626#L18">DetectFeedType</a></h3>
  245. <pre>func DetectFeedType(feed <a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#Reader">Reader</a>) <a href="index.html#FeedType">FeedType</a></pre>
  246. <p>
  247. DetectFeedType attempts to determine the type of feed
  248. by looking for specific xml elements unique to the
  249. various feed types.
  250. </p>
  251. <div id="example_DetectFeedType" class="toggle">
  252. <div class="collapsed">
  253. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  254. </div>
  255. <div class="expanded">
  256. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  257. <p>Code:</p>
  258. <pre class="code">
  259. feedData := `&lt;rss version=&#34;2.0&#34;&gt;
  260. &lt;channel&gt;
  261. &lt;title&gt;Sample Feed&lt;/title&gt;
  262. &lt;/channel&gt;
  263. &lt;/rss&gt;`
  264. feedType := gofeed.DetectFeedType(strings.NewReader(feedData))
  265. if feedType == gofeed.FeedTypeRSS {
  266. fmt.Println(&#34;Wow! This is an RSS feed!&#34;)
  267. }
  268. </pre>
  269. </div>
  270. </div>
  271. <h2 id="HTTPError">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go?s=211:271#L6">HTTPError</a></h2>
  272. <pre>type HTTPError struct {
  273. StatusCode <a href="../../../builtin/index.html#int">int</a>
  274. Status <a href="../../../builtin/index.html#string">string</a>
  275. }</pre>
  276. <p>
  277. HTTPError represents an HTTP error returned by a server.
  278. </p>
  279. <h3 id="HTTPError.Error">func (HTTPError) <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go?s=273:308#L11">Error</a></h3>
  280. <pre>func (err <a href="index.html#HTTPError">HTTPError</a>) Error() <a href="../../../builtin/index.html#string">string</a></pre>
  281. <h2 id="Image">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/feed.go?s=2851:2948#L60">Image</a></h2>
  282. <pre>type Image struct {
  283. URL <a href="../../../builtin/index.html#string">string</a> `json:&#34;url,omitempty&#34;`
  284. Title <a href="../../../builtin/index.html#string">string</a> `json:&#34;title,omitempty&#34;`
  285. }</pre>
  286. <p>
  287. Image is an image that is the artwork for a given
  288. feed or item.
  289. </p>
  290. <h2 id="Item">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/feed.go?s=1644:2611#L33">Item</a></h2>
  291. <pre>type Item struct {
  292. Title <a href="../../../builtin/index.html#string">string</a> `json:&#34;title,omitempty&#34;`
  293. Description <a href="../../../builtin/index.html#string">string</a> `json:&#34;description,omitempty&#34;`
  294. Content <a href="../../../builtin/index.html#string">string</a> `json:&#34;content,omitempty&#34;`
  295. Link <a href="../../../builtin/index.html#string">string</a> `json:&#34;link,omitempty&#34;`
  296. Updated <a href="../../../builtin/index.html#string">string</a> `json:&#34;updated,omitempty&#34;`
  297. UpdatedParsed *<a href="../../../time/index.html">time</a>.<a href="../../../time/index.html#Time">Time</a> `json:&#34;updatedParsed,omitempty&#34;`
  298. Published <a href="../../../builtin/index.html#string">string</a> `json:&#34;published,omitempty&#34;`
  299. PublishedParsed *<a href="../../../time/index.html">time</a>.<a href="../../../time/index.html#Time">Time</a> `json:&#34;publishedParsed,omitempty&#34;`
  300. Author *<a href="index.html#Person">Person</a> `json:&#34;author,omitempty&#34;`
  301. GUID <a href="../../../builtin/index.html#string">string</a> `json:&#34;guid,omitempty&#34;`
  302. Image *<a href="index.html#Image">Image</a> `json:&#34;image,omitempty&#34;`
  303. Categories []<a href="../../../builtin/index.html#string">string</a> `json:&#34;categories,omitempty&#34;`
  304. Enclosures []*<a href="index.html#Enclosure">Enclosure</a> `json:&#34;enclosures,omitempty&#34;`
  305. Extensions ext.<a href="index.html#Extensions">Extensions</a> `json:&#34;extensions,omitempty&#34;`
  306. Custom map[<a href="../../../builtin/index.html#string">string</a>]<a href="../../../builtin/index.html#string">string</a> `json:&#34;custom,omitempty&#34;`
  307. }</pre>
  308. <p>
  309. Item is the universal Item type that atom.Entry
  310. and rss.Item gets translated to. It represents
  311. a single entry in a given feed.
  312. </p>
  313. <h2 id="Parser">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go?s=497:659#L18">Parser</a></h2>
  314. <pre>type Parser struct {
  315. AtomTranslator <a href="index.html#Translator">Translator</a>
  316. RSSTranslator <a href="index.html#Translator">Translator</a>
  317. Client *<a href="../../../net/http/index.html">http</a>.<a href="../../../net/http/index.html#Client">Client</a>
  318. <span class="comment">// contains filtered or unexported fields</span>
  319. }</pre>
  320. <p>
  321. Parser is a universal feed parser that detects
  322. a given feed type, parsers it, and translates it
  323. to the universal feed type.
  324. </p>
  325. <h3 id="NewParser">func <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go?s=707:731#L27">NewParser</a></h3>
  326. <pre>func NewParser() *<a href="index.html#Parser">Parser</a></pre>
  327. <p>
  328. NewParser creates a universal feed parser.
  329. </p>
  330. <h3 id="Parser.Parse">func (*Parser) <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go?s=943:996#L38">Parse</a></h3>
  331. <pre>func (f *<a href="index.html#Parser">Parser</a>) Parse(feed <a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#Reader">Reader</a>) (*<a href="index.html#Feed">Feed</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  332. <p>
  333. Parse parses a RSS or Atom feed into
  334. the universal gofeed.Feed. It takes an
  335. io.Reader which should return the xml content.
  336. </p>
  337. <div id="example_Parser_Parse" class="toggle">
  338. <div class="collapsed">
  339. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  340. </div>
  341. <div class="expanded">
  342. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  343. <p>Code:</p>
  344. <pre class="code">
  345. feedData := `&lt;rss version=&#34;2.0&#34;&gt;
  346. &lt;channel&gt;
  347. &lt;title&gt;Sample Feed&lt;/title&gt;
  348. &lt;/channel&gt;
  349. &lt;/rss&gt;`
  350. fp := gofeed.NewParser()
  351. feed, err := fp.Parse(strings.NewReader(feedData))
  352. if err != nil {
  353. panic(err)
  354. }
  355. fmt.Println(feed.Title)
  356. </pre>
  357. </div>
  358. </div>
  359. <h3 id="Parser.ParseString">func (*Parser) <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go?s=2209:2265#L88">ParseString</a></h3>
  360. <pre>func (f *<a href="index.html#Parser">Parser</a>) ParseString(feed <a href="../../../builtin/index.html#string">string</a>) (*<a href="index.html#Feed">Feed</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  361. <p>
  362. ParseString parses a feed XML string and into the
  363. universal feed type.
  364. </p>
  365. <div id="example_Parser_ParseString" class="toggle">
  366. <div class="collapsed">
  367. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  368. </div>
  369. <div class="expanded">
  370. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  371. <p>Code:</p>
  372. <pre class="code">
  373. feedData := `&lt;rss version=&#34;2.0&#34;&gt;
  374. &lt;channel&gt;
  375. &lt;title&gt;Sample Feed&lt;/title&gt;
  376. &lt;/channel&gt;
  377. &lt;/rss&gt;`
  378. fp := gofeed.NewParser()
  379. feed, err := fp.ParseString(feedData)
  380. if err != nil {
  381. panic(err)
  382. }
  383. fmt.Println(feed.Title)
  384. </pre>
  385. </div>
  386. </div>
  387. <h3 id="Parser.ParseURL">func (*Parser) <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/parser.go?s=1708:1773#L63">ParseURL</a></h3>
  388. <pre>func (f *<a href="index.html#Parser">Parser</a>) ParseURL(feedURL <a href="../../../builtin/index.html#string">string</a>) (feed *<a href="index.html#Feed">Feed</a>, err <a href="../../../builtin/index.html#error">error</a>)</pre>
  389. <p>
  390. ParseURL fetches the contents of a given url and
  391. attempts to parse the response into the universal feed type.
  392. </p>
  393. <div id="example_Parser_ParseURL" class="toggle">
  394. <div class="collapsed">
  395. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  396. </div>
  397. <div class="expanded">
  398. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  399. <p>Code:</p>
  400. <pre class="code">
  401. fp := gofeed.NewParser()
  402. feed, err := fp.ParseURL(&#34;http://feeds.twit.tv/twit.xml&#34;)
  403. if err != nil {
  404. panic(err)
  405. }
  406. fmt.Println(feed.Title)
  407. </pre>
  408. </div>
  409. </div>
  410. <h2 id="Person">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/feed.go?s=2680:2779#L53">Person</a></h2>
  411. <pre>type Person struct {
  412. Name <a href="../../../builtin/index.html#string">string</a> `json:&#34;name,omitempty&#34;`
  413. Email <a href="../../../builtin/index.html#string">string</a> `json:&#34;email,omitempty&#34;`
  414. }</pre>
  415. <p>
  416. Person is an individual specified in a feed
  417. (e.g. an author)
  418. </p>
  419. <h2 id="Translator">type <a href="http://localhost:6060/src/github.com/mmcdole/gofeed/translator.go?s=304:377#L6">Translator</a></h2>
  420. <pre>type Translator interface {
  421. Translate(feed interface{}) (*<a href="index.html#Feed">Feed</a>, <a href="../../../builtin/index.html#error">error</a>)
  422. }</pre>
  423. <p>
  424. Translator converts a particular feed (atom.Feed or rss.Feed)
  425. into the generic Feed struct
  426. </p>
  427. <h2 id="pkg-subdirectories">Subdirectories</h2>
  428. <div class="pkg-dir">
  429. <table>
  430. <tr>
  431. <th class="pkg-name">Name</th>
  432. <th class="pkg-synopsis">Synopsis</th>
  433. </tr>
  434. <tr>
  435. <td colspan="2"><a href="../index.html">..</a></td>
  436. </tr>
  437. <tr>
  438. <td class="pkg-name" style="padding-left: 0px;">
  439. <a href="atom/index.html">atom</a>
  440. </td>
  441. <td class="pkg-synopsis">
  442. </td>
  443. </tr>
  444. <tr>
  445. <td class="pkg-name" style="padding-left: 0px;">
  446. <a href="cmd/index.html">cmd</a>
  447. </td>
  448. <td class="pkg-synopsis">
  449. </td>
  450. </tr>
  451. <tr>
  452. <td class="pkg-name" style="padding-left: 20px;">
  453. <a href="cmd/ftest/index.html">ftest</a>
  454. </td>
  455. <td class="pkg-synopsis">
  456. </td>
  457. </tr>
  458. <tr>
  459. <td class="pkg-name" style="padding-left: 0px;">
  460. <a href="extensions/index.html">extensions</a>
  461. </td>
  462. <td class="pkg-synopsis">
  463. </td>
  464. </tr>
  465. <tr>
  466. <td class="pkg-name" style="padding-left: 0px;">
  467. <a href="rss/index.html">rss</a>
  468. </td>
  469. <td class="pkg-synopsis">
  470. </td>
  471. </tr>
  472. </table>
  473. </div>
  474. <div id="footer">
  475. Build version go1.6.<br>
  476. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  477. the content of this page is licensed under the
  478. Creative Commons Attribution 3.0 License,
  479. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  480. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  481. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  482. </div>
  483. </div><!-- .container -->
  484. </div><!-- #page -->
  485. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  486. <script type="text/javascript" src="../../../../lib/godoc/jquery.js"></script>
  487. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.js"></script>
  488. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.edit.js"></script>
  489. <script type="text/javascript" src="../../../../lib/godoc/godocs.js"></script>
  490. </body>
  491. </html>