- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_example.py
More file actions
Latest commit
38 lines (27 loc) · 992 Bytes
/
Copy pathmain_example.py
File metadata and controls
38 lines (27 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python2.7
importsys
sys.path.append('./src')
fromscraper.operationsimportCountNumberOfElements, ListOcurrences
fromscraper.resultprintersimportConsolePrinter
fromscraper.scraperimportdefaultUrlScraperasScraper
url="http://ordergroove.com/company"
defmain():
"""
This runs an example petition to the scraper
asking for the number of html elements and the
5 most used tags on the page that is stored in
global variable "url").
Scraper was made in a way to be extendable by
Operations, and also the output was decoupled using an abstract
printer (only consoleOutput was implemented by now)
"""
# Setting up & Running the Scraper
scraper=Scraper(url)
scraper.addOperation(CountNumberOfElements())
scraper.addOperation(ListOcurrences(limit=5))
scraper.run()
# Printing results
consolePrinter=ConsolePrinter()
scraper.printResults(consolePrinter)
if__name__=='__main__':
main()