On 11/07/2015 23:17, Simon Evans wrote:
Dear Programmers,
Thank you for your advice regarding giving the console a current address in the 
code for it to access the html file.

The console seems to accept the code to that extent, but when I input the two 
lines of code intended to access the location of a required word, the console 
rejects it re :

AttributeError:'NoneType' object has no attribute 'li'

However the document 'EcologicalPyramid.html' does contain the words 'li' and 
'ul', in its text. I am not sure as to how the input is arranged to output 
'plants' which is also in the documents text, but that is the word the code is 
meant to elicit.

I enclose the pertinent code as input and output from the console, and the html 
code for the document 'EcologicalPyramid.html'

Thank you in advance for your help.

---------------------------------------------------------------------
with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as ecological_pyramid:
soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html","lxml")

Beautiful Soup takes a string or a file handle so as it's good practise to use the "with open" construct this should do it:-

soup = BeautifulSoup(ecological_pyramid,"lxml")

but do you actually need the "lxml", with the simple parsing I've done in the past I've never used it?

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to