Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'unicode' object is not callable

I want to get the source but I have the ERROR:

>> from selenium import webdriver
>> driver = webdriver.PhantomJS()
>> url='http://google.com'
>> cont=driver.page_source(url)
>> print cont
>> driver.quit()

ERROR:

Traceback (most recent call last):
  File "u.py", line 6, in <module>
    cont=driver.page_source(url)
TypeError: 'unicode' object is not callable
like image 457
MLSC Avatar asked Nov 05 '14 14:11

MLSC


1 Answers

This error occurs when we call unicode objects as a function. For example:

a = u'this is unicode string'

if you do a() somewhere in code you get this error

In your case as pointed out page_source is a unicode string and not a callable function. So this page_source(url) is giving above error.

like image 112
viky.pat Avatar answered Oct 27 '22 14:10

viky.pat