czne.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from sites.default import DefaultSite
  2. from helper.sites.query import Query
  3. class Czne(DefaultSite):
  4. def __init__(self):
  5. super().__init__()
  6. self.url = 'https://nowoscimuzyczne.eu'
  7. self.query = Query(self, 'POST')\
  8. .add_parameter('do', 'search')\
  9. .add_parameter('subaction', 'search')\
  10. .add_parameter('story', '{0}')
  11. self.structure\
  12. .set_container_path('div#dle-content')\
  13. .set_item_path('article.short-story')\
  14. .set_title_path('div.short-title')\
  15. .set_url_path('div.wpisplayer script:first')
  16. self.request\
  17. .add_header('Referer', self.url + '/')\
  18. .add_header('Origin', self.url)\
  19. .add_header('Content-Type', 'application/x-www-form-urlencoded')
  20. def format_url(self, field):
  21. script = field.text()
  22. _start = 'var link=\''
  23. _end = '\';'
  24. start = script.find(_start)
  25. if start > -1:
  26. end = script.find(_end)
  27. if end > -1 and end > start:
  28. return script[start+len(_start):end]
  29. return None