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.

138 lines
2.9 KiB

  1. # pysitemap
  2. > Sitemap generator
  3. ## Installation
  4. ```
  5. pip install sitemap-generator
  6. ```
  7. ## Requirements
  8. ```
  9. asyncio
  10. aiofile
  11. aiohttp
  12. ```
  13. ## Example 1
  14. ```
  15. import sys
  16. import logging
  17. from pysitemap import crawler
  18. if __name__ == '__main__':
  19. if '--iocp' in sys.argv:
  20. from asyncio import events, windows_events
  21. sys.argv.remove('--iocp')
  22. logging.info('using iocp')
  23. el = windows_events.ProactorEventLoop()
  24. events.set_event_loop(el)
  25. # root_url = sys.argv[1]
  26. root_url = 'https://www.haikson.com'
  27. crawler(root_url, out_file='sitemap.xml')
  28. ```
  29. ## Example 2
  30. ```
  31. import sys
  32. import logging
  33. from pysitemap import crawler
  34. if __name__ == '__main__':
  35. root_url = 'https://mytestsite.com/'
  36. crawler(
  37. root_url,
  38. out_file='sitemap.xml',
  39. maxtasks=100,
  40. verifyssl=False,
  41. exclude_urls=[
  42. '/git/.*(action|commit|stars|activity|followers|following|\?sort|issues|pulls|milestones|archive|/labels$|/wiki$|/releases$|/forks$|/watchers$)',
  43. '/git/user/(sign_up|login|forgot_password)',
  44. '/css',
  45. '/js',
  46. 'favicon',
  47. '[a-zA-Z0-9]*\.[a-zA-Z0-9]*$',
  48. '\?\.php',
  49. ],
  50. headers={'User-Agent': 'Crawler'},
  51. # TZ offset in hours
  52. timezone_offset=3,
  53. changefreq={
  54. "/git/": "weekly",
  55. "/": "monthly"
  56. },
  57. priorities={
  58. "/git/": 0.7,
  59. "/metasub/": 0.6,
  60. "/": 0.5
  61. }
  62. )
  63. ```
  64. ### TODO
  65. - big sites with count of pages more then 100K will use more then 100MB
  66. memory. Move queue and done lists into database. Write Queue and Done
  67. backend classes based on
  68. - Lists
  69. - SQLite database
  70. - Redis
  71. - Write api for extending by user backends
  72. ## Changelog
  73. **v. 0.9.3**
  74. Added features:
  75. - Option to enable/disable website SSL certificate verification (True/False)
  76. - Option to exclude URL patterns (`list`)
  77. - Option to provide custom HTTP request headers to web server (`dict`)
  78. - Add support for <lastmod> tags (XML)
  79. - Configurable timezone offset for lastmod tag
  80. - Add support for <changefreq> tags (XML)
  81. - Input (`dict`): `{ url_regex: changefreq_value, url_regex: ... }`
  82. - Add support for <priority> tags (XML)
  83. - Input (`dict`): `{ url_regex: priority_value, url_regex: ... }`
  84. - Reduce default concurrent max tasks from `100` to `10`
  85. **v. 0.9.2**
  86. - todo queue and done list backends
  87. - created very slowest sqlite backend for todo queue and done lists (1000 url writing for 3 minutes)
  88. - tests for sqlite_todo backend
  89. **v. 0.9.1**
  90. - extended readme
  91. - docstrings and code commentaries
  92. **v. 0.9.0**
  93. - since this version package supports only python version `>=3.7`
  94. - all functions recreated but api saved. If You use this package, then
  95. just update it, install requirements and run process
  96. - all requests works asynchronously