Sitemap generator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
793 B

4 years ago
  1. import asyncio
  2. import signal
  3. from pysitemap.base_crawler import Crawler
  4. def crawler(root_url, out_file, out_format='xml', maxtasks=100):
  5. """
  6. run crowler
  7. :param root_url: Site root url
  8. :param out_file: path to the out file
  9. :param out_format: format of out file [xml, txt]
  10. :param maxtasks: max count of tasks
  11. :return:
  12. """
  13. loop = asyncio.get_event_loop()
  14. c = Crawler(root_url, out_file=out_file, out_format=out_format, maxtasks=maxtasks)
  15. loop.run_until_complete(c.run())
  16. try:
  17. loop.add_signal_handler(signal.SIGINT, loop.stop)
  18. except RuntimeError:
  19. pass
  20. print('todo_queue:', len(c.todo_queue))
  21. print('busy:', len(c.busy))
  22. print('done:', len(c.done), '; ok:', sum(c.done.values()))
  23. print('tasks:', len(c.tasks))