Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- import js2py
- import time
- import requests
- from urllib.parse import urljoin
- from bs4 import BeautifulSoup
- def main(url):
- # Put url here
- dl = None
- try:
- page = requests.get(url)
- if page:
- soup = BeautifulSoup(page.text, 'html.parser')
- script = soup.find(
- 'div', {
- 'style' : 'float: right; width: 214px; vertical-align: top; margin-right: 83px; margin-top: -10px; margin-left: 20px; text-align: center;'
- }
- ).find('script')
- js = str(script).replace(
- 'document.getElementById(\'dlbutton\').omg', 'c'
- ).replace(
- 'document.getElementById(\'dlbutton\').href =', 'return'
- ).replace(
- '<script type="text/javascript">', 'function getLink() {'
- ).replace(
- '</script>', '}'
- )
- js += '\ngetLink();'
- dl = urljoin(os.path.dirname(url), js2py.eval_js(js))
- if dl:
- os.system('wget "%s"' % dl)
- except KeyboardInterrupt:
- print('\n\nExitting . . .')
- sys.exit(1)
- except requests.ConnectionError as err:
- print('Connection Error: %s' % err)
- sys.exit(2)
- if __name__ == '__main__':
- start_time = time.time()
- main(sys.argv[1])
- print('--- %s seconds ---' % (time.time() - start_time))
Add Comment
Please, Sign In to add comment