-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to scrape, click_link, then scrape again. (Only for…
… firefox agent)
- Loading branch information
Mikkel Garcia
committed
Apr 6, 2009
1 parent
17de69f
commit 2a82536
Showing
8 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
$:.unshift File.join(File.dirname(__FILE__), '../../../lib') | ||
|
||
require 'scrubyt' | ||
require 'scrubyt/output/result_dumper' | ||
|
||
#Example of: Using the next_page command with onclick='' hrefs. | ||
|
||
### Doesn't work, as next_page doesn't click links | ||
data = Scrubyt::Extractor.define(:agent => :firefox) do | ||
fetch("file://"+File.expand_path(File.join(File.dirname(__FILE__), "page_1.html"))) | ||
|
||
entry '//div' | ||
|
||
next_page 'Next' | ||
end | ||
|
||
puts "First results :" | ||
puts data.to_xml | ||
|
||
puts "---------------" | ||
|
||
### Doesn't work, all the results are the same :( | ||
|
||
data = Scrubyt::Extractor.define(:agent => :firefox) do | ||
fetch("file://"+File.expand_path(File.join(File.dirname(__FILE__), "page_1.html"))) | ||
|
||
while(true) | ||
entry '//div' | ||
|
||
begin | ||
click_link 'Next' | ||
rescue Watir::Exception::UnknownObjectException | ||
puts "Reached the end. Breaking" | ||
break | ||
end | ||
end | ||
end | ||
puts "Second results:" | ||
puts data.to_xml | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<body> | ||
<div>1</div> | ||
<div>2</div> | ||
<div>3</div> | ||
<form id='nextPage' action='page_2.html'> | ||
<a onclick='document.getElementById("nextPage").submit(); return false' href="#">Next</a> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<body> | ||
<div>4</div> | ||
<div>5</div> | ||
<div>6</div> | ||
<form id='nextPage' action='page_3.html'> | ||
<a onclick='document.getElementById("nextPage").submit(); return false' href="#">Next</a> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<body> | ||
<div>7</div> | ||
<div>8</div> | ||
<div>9</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters