Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
f2d4dd2d
...
f2d4dd2db3ce5777fc34081d3cf660f17c718fff
authored
2013-01-22 12:06:23 +0100
by
Narno
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Fixed Twitter URL and selector in screenshot.js (and screenshot.coffee) sample
1 parent
33e0f6ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
samples/screenshot.coffee
samples/screenshot.js
samples/screenshot.coffee
View file @
f2d4dd2
...
...
@@ -16,8 +16,8 @@ if not twitterAccount or not filename or not /\.(png|jpg|pdf)$/i.test filename
.
echo
(
"Usage: $ casperjs screenshot.coffee <twitter-account> <filename.[jpg|png|pdf]>"
)
.
exit
(
1
)
casper
.
start
"https://twitter.com/#
!/
#
{
twitterAccount
}
"
,
->
@
waitForSelector
".
tweet-row
"
,
(
->
casper
.
start
"https://twitter.com/
#{
twitterAccount
}
"
,
->
@
waitForSelector
".
stream-container
"
,
(
->
@
captureSelector
filename
,
"html"
@
echo
"Saved screenshot of
#{
@
getCurrentUrl
()
}
to
#{
filename
}
"
),
(
->
...
...
samples/screenshot.js
View file @
f2d4dd2
...
...
@@ -3,7 +3,7 @@
/**
* This script will capture a screenshot of a twitter account page
* Usage: $ casperjs screenshot.
coffee
<twitter-account> <filename.[jpg|png|pdf]>
* Usage: $ casperjs screenshot.
js
<twitter-account> <filename.[jpg|png|pdf]>
*/
var
casper
=
require
(
"casper"
).
create
({
...
...
@@ -18,13 +18,13 @@ var filename = casper.cli.get(1);
if
(
!
twitterAccount
||
!
filename
||
!
/
\.(
png|jpg|pdf
)
$/i
.
test
(
filename
))
{
casper
.
echo
(
"Usage: $ casperjs screenshot.
coffee
<twitter-account> <filename.[jpg|png|pdf]>"
)
.
echo
(
"Usage: $ casperjs screenshot.
js
<twitter-account> <filename.[jpg|png|pdf]>"
)
.
exit
(
1
)
;
}
casper
.
start
(
"https://twitter.com/
#!/
"
+
twitterAccount
,
function
()
{
this
.
waitForSelector
(
".
tweet-row
"
,
(
function
()
{
casper
.
start
(
"https://twitter.com/"
+
twitterAccount
,
function
()
{
this
.
waitForSelector
(
".
stream-container
"
,
(
function
()
{
this
.
captureSelector
(
filename
,
"html"
);
this
.
echo
(
"Saved screenshot of "
+
(
this
.
getCurrentUrl
())
+
" to "
+
filename
);
}),
(
function
()
{
...
...
Please
register
or
sign in
to post a comment