-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Iury O. G. Figueiredo
committed
Jul 22, 2017
1 parent
434fab5
commit 699264b
Showing
5 changed files
with
93 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
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,33 @@ | ||
""" | ||
This example extract just the quotes, you end up with a structure like: | ||
[quote0, quote1, ...] | ||
Note: It uses beautifulsoup4 :) | ||
""" | ||
|
||
from sukhoi import MinerBS4, core | ||
|
||
class QuoteMiner(MinerBS4): | ||
def run(self, dom): | ||
elems = dom.find_all('div', {'class':'quote'}) | ||
self.extend(map(self.extract_quote, elems)) | ||
|
||
elem = dom.find('li', {'class', 'next'}) | ||
if elem: self.next(elem.find('a').get('href')) | ||
|
||
def extract_quote(self, elem): | ||
quote = elem.find('span', {'class': 'text'}) | ||
return quote.text | ||
|
||
if __name__ == '__main__': | ||
URL = 'http://quotes.toscrape.com/' | ||
quotes = QuoteMiner(URL) | ||
core.gear.mainloop() | ||
|
||
print quotes | ||
|
||
|
||
|
||
|
||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
untwisted==1.3.2 | ||
websnake==1.1.0 | ||
untwisted==1.4.1 | ||
websnake==1.3.0 | ||
ehp==1.1.0 | ||
lxml | ||
bs4 | ||
|
||
|
||
|
||
|
||
|
||
|
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