Question

I have been looking all over and I see how to download vimeo videos using python. I so far have this code.I can get to the parent page but I cannot do anything to hit that iframe. I was thinking the best way to do this would be login and hit the iframe and download the video from there but I am missing something. do any of you have any ideas? let me know if you need more info and as always thank you for your time.

import spynner
import os, sys, urllib

os.system("dir")

browser = spynner.Browser()
#browser.show()
url = 'https://somelink.php'
browser.load("https://somelink2.php")
browser.wk_fill("input[name=log]", "loginname")
browser.wk_fill("input[name=pwd]", "password")
browser.click("#wp-submit")
print browser.url, len(browser.html)
browser.load("http://somelink3-00000333/")
browser.click("//player.vimeo.com/video/747474749")
print browser.html

Here is the embedded video that I would like to download.

<iframe src="//player.vimeo.com/video/747474749" width="500" height="281"
frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
Was it helpful?

Solution

The Site allowed for Javascript to be run from the client side. so in short a simply running javascript to access the link is enough. javascript:window.location.href="%s"; '%uls is really all that was needed to have this happen. I hope it helps others in the future and perhaps there is a better way to do this please let me know.

def getvideourl(htmldoc): 
        downloadurls = re.findall("//player.+video.\d+", htmldoc) 
        for uls in downloadurls: 
            uls.encode('ascii','ignore') 
            javasinject = 'javascript:window.location.href="%s"; '%uls 
            return javasinject 

    def jsinject(link): 
        str(link) 
        browser.runjs(link) 


    jsinject(str(getvideourl(browser.html))) 
    browser._wait_load()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top