python - NoneType object has no attribute 'encode' (Web Scrapping) -


i getting error

'nonetype' object has no attribute 'encode'

when run code

url = soup.find('div',attrs={"class":"entry-content"}).findall('div', attrs={"class":none})    fobj = open('d:\scrapping\parveen_urls.txt', 'w')   getting in url:    fobj.write(getting.string.encode('utf8')) 

but when use find instead of findall 1 url. how urls object findall?

'nonetype' object has no attribute 'encode'

you using .string. if tag has multiple children .string none (docs):

if tag’s child tag, , tag has .string, parent tag considered have same .string child:

use .get_text() instead.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

post - imageshack API cURL -

dataset - MPAndroidchart returning no chart Data available -