Guest User

Untitled

a guest
Mar 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import sys
  2. import os
  3. import js2py
  4. import time
  5. import requests
  6. from urllib.parse import urljoin
  7. from bs4 import BeautifulSoup
  8.  
  9. def main(url):
  10. # Put url here
  11. dl = None
  12. try:
  13. page = requests.get(url)
  14. if page:
  15. soup = BeautifulSoup(page.text, 'html.parser')
  16. script = soup.find(
  17. 'div', {
  18. 'style' : 'float: right; width: 214px; vertical-align: top; margin-right: 83px; margin-top: -10px; margin-left: 20px; text-align: center;'
  19. }
  20. ).find('script')
  21. js = str(script).replace(
  22. 'document.getElementById(\'dlbutton\').omg', 'c'
  23. ).replace(
  24. 'document.getElementById(\'dlbutton\').href =', 'return'
  25. ).replace(
  26. '<script type="text/javascript">', 'function getLink() {'
  27. ).replace(
  28. '</script>', '}'
  29. )
  30. js += '\ngetLink();'
  31. dl = urljoin(os.path.dirname(url), js2py.eval_js(js))
  32. if dl:
  33. os.system('wget "%s"' % dl)
  34. except KeyboardInterrupt:
  35. print('\n\nExitting . . .')
  36. sys.exit(1)
  37. except requests.ConnectionError as err:
  38. print('Connection Error: %s' % err)
  39. sys.exit(2)
  40.  
  41. if __name__ == '__main__':
  42. start_time = time.time()
  43. main(sys.argv[1])
  44. print('--- %s seconds ---' % (time.time() - start_time))
Add Comment
Please, Sign In to add comment