@@ -45,15 +45,15 @@ npm install x-ray
45
45
46
46
## API
47
47
48
- #### Xray(url)
48
+ #### ` Xray(url) `
49
49
50
50
Initialize ` xray ` with a ` url `
51
51
52
52
``` js
53
53
xray (' http://google.com' )
54
54
```
55
55
56
- #### Xray#select(<string|object|array> schema)
56
+ #### ` Xray#select(<string|object|array> schema) `
57
57
58
58
The elements you'd like to select. Uses [ x-ray-select] ( https://github.com/lapwinglabs/x-ray-select ) for matching the elements on the page.
59
59
@@ -155,7 +155,7 @@ xray('http://mat.io')
155
155
});
156
156
```
157
157
158
- #### Xray#use(<function > fn)
158
+ #### ` Xray#use(<function> fn) `
159
159
160
160
Add a plugin to augment Xray's current functionality.
161
161
@@ -168,7 +168,7 @@ xray('http://google.com')
168
168
.use (phantom (options))
169
169
```
170
170
171
- #### Xray#throws(<boolean > throws)
171
+ #### ` Xray#throws(<boolean> throws) `
172
172
173
173
This tells x-ray whether or not to throw if it encounters an error while parsing. Defaults to throwing (` true ` ).
174
174
@@ -177,7 +177,7 @@ xray('https://github.com/')
177
177
.throws (false )
178
178
```
179
179
180
- #### Xray#paginate(<string > selector)
180
+ #### ` Xray#paginate(<string> selector) `
181
181
182
182
Crawl the website by passing a selector that contains a URL to the next or previous page:
183
183
@@ -193,7 +193,7 @@ xray('https://github.com/')
193
193
.paginate (' .prev[href]' )
194
194
```
195
195
196
- #### Xray#delay(<number > from, < number:optional > to)
196
+ #### ` Xray#delay(<number> from, <number:optional> to) `
197
197
198
198
When paginating, this will delay the next request randomly between ` from ` and ` to ` milliseconds.
199
199
@@ -214,7 +214,7 @@ xray('http://github.com')
214
214
.delay (5000 )
215
215
```
216
216
217
- #### Xray#prepare(<string|object> str, <function > fn)
217
+ #### ` Xray#prepare(<string|object> str, <function> fn) `
218
218
219
219
You can prepare the data that you scrape for output
220
220
@@ -249,7 +249,7 @@ xray('mat.io')
249
249
```
250
250
251
251
252
- #### Xray#format(<function > fn)
252
+ #### ` Xray#format(<function> fn) `
253
253
254
254
Specify a custom formatting function for each selected element.
255
255
@@ -270,11 +270,11 @@ xray('https://github.com/stars/matthewmueller')
270
270
271
271
` TODO ` : specify an "end", so you can do ` xray.format(html) ` and get back html.
272
272
273
- #### Xray#limit(<number > limit)
273
+ #### ` Xray#limit(<number> limit) `
274
274
275
275
When paginating, this specifies a limit to the number of pages x-ray should crawl. Defaults to no limit (` Infinity ` ).
276
276
277
- #### Xray#run(< function:optional > fn)
277
+ #### ` Xray#run(<function:optional> fn) `
278
278
279
279
Start the scraper, calling ` fn ` when we're done scraping.
280
280
@@ -293,7 +293,7 @@ var title = yield xray('http://google.com').select('title').run();
293
293
// title is "Google"
294
294
```
295
295
296
- #### Xray#write(<string|WritableStream> filepath) -> WritableStream
296
+ #### ` Xray#write(<string|WritableStream> filepath) -> WritableStream `
297
297
298
298
Start the scraper, streaming each page to ` filepath ` . Returns a [ ` WritableStream ` ] ( http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_writable ) .
299
299
0 commit comments