i'm trying to import the BeautifulSoup library directly in my python script, i can't install it because i'm using it in my Synology DS213+, so i'm trying to do this:
from BeautifulSoup import BeautifulSoup
import urllib, urllib2
opener = urllib2.build_opener(urllib2.HTTPHandler(debuglevel=0))
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
ins = open( "str.txt", "r" )
array = []
for line in ins:
array.append(line.strip())
ins.close()
for riga in array:
print riga
html = opener.open("http://www.mysite.com/?s="+riga)
soup = BeautifulSoup(html)
soup.find_all('a')
for link in soup.find_all('a'):
print link.get('href')
but i receive this error:
Traceback (most recent call last):
File "myscript.py", line 17, in <module>
soup.find_all('a')
TypeError: 'NoneType' object is not callable
i can't understand why, i put BeautifulSoup.py in the myscript.py directory, and i import in this way:
from BeautifulSoup import BeautifulSoup
what is wrong?
TypeErroris notImportError. If it is all you've got then you've already importedBeautifulSoupsuccessfully. Whether your installation is broken is another question.