web scraping - TypeError: cannot concatenate 'str' and 'NoneType' objects python bs4 -


i wrote simple program in python scraping. new this. cannot understand thing provided in bs4 documentation

from bs4 import beautifulsoup import urllib2 url="http://www.99acres.com/property-in-velachery-chennai-south-ffid?" page=urllib2.urlopen(url) soup = beautifulsoup(page.read()) properties=soup.findall('a',{'class':'f15'}) eachproperty in properties:  print eachproperty['href']+","+eachproperty.string 

i following error

    /residential-apartment-flat-in-velachery-chennai south-2-bedroom-bhk-for-sale-spid-y10765227,2 bedroom, residential apartment in velachery traceback (most recent call last):   file "properties.py", line 8, in <module>     print eachproperty['href']+","+eachproperty.string typeerror: cannot concatenate 'str' , 'nonetype' objects 

the problem either eachproperty['href'] none or eachproperty.string none.

you should test see if these variables none before try concatenate them (i.e. + them).

try

print eachproperty['href'], eachproperty.string 

if want print them out, see 1 none.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -