Skip to content Skip to sidebar Skip to footer

Python: Get Download Link From Javascript Button

I am trying to get my script to download subtitles from www.subscene.com. The problem is that the download button on webpage is made in java, and for some reason i cannot download

Solution 1:

As John said this is not the file but javascript code. So instead of getting that file using urllib.urlretrieve, you can execute the javascript which downloads the files in turn. This can be done using selenium module -

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://subscene.com/english/How-I-Met-Your-Mother-Seventh-Season/subtitle-482407.aspx')        
browser.execute_script('WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("s$lc$bcr$downloadLink", "", true, "", "/english/How-I-Met-Your-Mother-Seventh-Season/subtitle-482407-dlpath-90698/zip.zipx", false, true))')
raw_input()

I got this javascript snippet using Firebug.

Post a Comment for "Python: Get Download Link From Javascript Button"