-
Notifications
You must be signed in to change notification settings - Fork 1
/
kicker.py
52 lines (40 loc) · 1.3 KB
/
kicker.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from toolset.RabbitPSQLMixin import RabbitPSQLMixin
from scraper import Scraper
import asyncio
from urllib.parse import urljoin
from lxml.html import fromstring
from toolset.FileIO import load_yml_file
from toolset.LxmlWrapper import sxpath
from toolset.AsyncRabbitPSQLMixin import AsyncRabbitPSQLMixin
from toolset.BaseArgumentParser import base_argument_parser
from toolset.LogConfig import init_logger
parser = base_argument_parser()
argv = parser.parse_args()
init_logger(
argv.log_level,
argv.log_file,
argv.log_file_level,
argv.log_host,
argv.log_port,
argv.log_network_level,
)
# logging
from toolset.BaseArgumentParser import base_argument_parser
import logging
from toolset.LogConfig import init_logger
# first is module, second is object in module
from toolset.FileIO import load_yml_file
URL = "http://books.toscrape.com/"
def main():
LOG.info("Start of kicker file")
LOG = logging.getLogger(__name__)
config = load_yml_file("./local_config.yml")
loop = asyncio.get_event_loop()
scraper = Scraper(config=config, loop=loop)
loop.run_until_complete(scraper.start())
URLdict = {}
URLdict["URL"] = URL
loop.run_until_complete(scraper.publish("main_page", URLdict, scraper.queue))
LOG.info("End of kicker file")
if __name__ == "__main__":
main()