Skip to content

Commit

Permalink
Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreak committed Nov 15, 2012
1 parent 73dae64 commit b28a9db
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/basic_requests.coffee
@@ -0,0 +1,25 @@
re = require('request-enhanced')

re.get 'http://www.example.com', (error, data) ->
console.log "Fetched: #{data.length} characters"

re.get 'http://www.example.com', "#{__dirname}/test.txt", (error, data) ->
console.log 'Fetched:', data

regex =
firstLink:
regex: /<a href="(.*?)">(.*?)<\/a>/i
results:
0: 'html'
1: 'href'
2: 'text'
allLinks:
regex: /<a href="(.*?)">(.*?)<\/a>/gi
results:
0: 'html'
1: 'href'
2: 'text'

re.get 'http://www.example.com', regex, (error, data, results) ->
console.log "Fetched: #{data.length} characters to find:"
console.log results
39 changes: 39 additions & 0 deletions examples/basic_requests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b28a9db

Please sign in to comment.