G+_Rud Dog Posted August 1, 2015 Share Posted August 1, 2015 what am i overlooking >>> import bs4 >>> exampleFile = open('example.html') >>> exampleSoup = bs4.BeautifulSoup(exampleFile.read()) >>> elems = exampleSoup.select('#author') >>> type(elems) >>> len(elems) 0 >>> type(elems[0]) Traceback (most recent call last): File "", line 1, in type(elems[0]) IndexError: list index out of range Link to comment Share on other sites More sharing options...
G+_Jeff Brand Posted August 2, 2015 Share Posted August 2, 2015 When len(elems) is 0 that means there are no items in the list, not that there's one available at the 0 slot. Just remember that the max index in an array will be len(array)-1.? Link to comment Share on other sites More sharing options...
G+_Rud Dog Posted August 2, 2015 Author Share Posted August 2, 2015 Thank everyone that me know the file being asked for information was either poorly created, lacking the author section, or was plain empty. That was the case script is correctly functioning. Link to comment Share on other sites More sharing options...
Recommended Posts