0

I am trying to download an entire play list for Android development tutorial from Youtube. So I used savefrom for generating playlist for download. But the problem is that I have so many videos in that playlist. So, I decided to write a python script for making this work simpler. But the problem is it uses Java Script to generate the link so I cant able to fetch generated link using javascript()

Example: http://ssyoutube.com/watch?v=AfleuRtrJoA It takes 5 sec to generate download links.

I want to get page source only after 5 sec from the browse.

For this kind of work I found a good package named selenium.

import time
from selenium import webdriver

def savefromnotnet(url):
    browser = webdriver.Firefox() # Get local session of firefox
    browser.get(url) # Load page
    time.sleep(5) # Let the page load, will be added to the API
    return browser.page_source()

source = savefromnotnet("http://ssyoutube.com/watch?v=AfleuRtrJoA")

The savefromnotnet function open's Firefox and it will request the url, up to this every thing works fine. But when I want to get page source browser.page_source() it shows the following error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 523, in runfile
    execfile(filename, namespace)
  File "C:\Users\BK\Desktop\Working Folder\Python Temp\temp.py", line 10, in <module>
    source = savefromnotnet("http://ssyoutube.com/watch?v=AfleuRtrJoA")
  File "C:\Users\BK\Desktop\Working Folder\Python Temp\temp.py", line 8, in savefromnotnet
    return browser.page_source()
TypeError: 'unicode' object is not callable
1
  • Add link to playlist. And show your code. Commented Jul 5, 2013 at 23:51

2 Answers 2

2

Error occured on following line.

return browser.page_source()

I think brackets did not need.

return browser.page_source
Sign up to request clarification or add additional context in comments.

Comments

0

I think not !

pcode = wdriver.page_source()

is absoluteley right call. By auto-complete in python ide.

I have the same problem. Looks like we need to encode page-sourse text variable in somethind like classic ANSI

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.