Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yPhil
feedrat
Commits
ef644f30
Commit
ef644f30
authored
Jan 18, 2019
by
yPhil
Browse files
Promises
parent
abdae87c
Changes
1
Hide whitespace changes
Inline
Side-by-side
feedrat.js
View file @
ef644f30
const
cheerio
=
require
(
'
cheerio
'
),
rp
=
require
(
'
request-promise-native
'
);
const
options
=
{
method
:
'
GET
'
,
uri
:
'
https://yphil.bitbucket.io/
'
};
module
.
exports
=
function
(
u
)
{
return
rp
(
u
)
.
then
(
function
(
body
)
{
console
.
log
(
'
ok: (%s)
'
);
module
.
exports
=
function
(
u
,
callback
)
{
return
rp
(
u
).
then
(
function
(
body
)
{
const
$
=
cheerio
.
load
(
body
);
const
$
=
cheerio
.
load
(
body
);
if
(
$
(
'
a
'
).
length
>
0
)
{
$
(
'
a
'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'
href
'
))
{
if
(
$
(
this
).
attr
(
'
title
'
))
console
.
log
(
'
$(this).attr("href"): (%s)
'
,
$
(
this
).
attr
(
'
title
'
));
// console.log("got: "
// + body);
}
else
{
console
.
log
(
'
nothing: (%s)
'
);
}
});
}
if
(
$
(
'
a
'
).
length
>
0
)
{
$
(
'
a
'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'
href
'
))
{
if
(
$
(
this
).
attr
(
'
title
'
))
callback
(
$
(
this
).
attr
(
'
title
'
));
// console.log("got: "
// + body);
}
else
{
console
.
log
(
'
nothing: (%s)
'
);
}
});
}
})
.
catch
(
function
(
err
)
{
// POST failed...
console
.
log
(
"
ERROR:
"
+
err
)
;
});
})
.
catch
(
function
(
err
)
{
// POST failed...
console
.
log
(
"
ERROR:
"
+
err
);
return
err
;
});
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment