I am using bs4 and scraping links, in some cases in the loop there is no <a href=""> tag
.
So in that case I want to input the text
attribute of the element.
my sample code,
base_url = "http://example.com"
abc = base_url + str(tds.a['href']) if tds.a['href'] else tds.text
Exception is thrown
TypeError: 'NoneType' object is not subscriptable
This is how my td
element looks like:
<td nowrap=""><font face="Arial" size="1"><a href="view_document?docurl=http://www.envirostor.dtsc.ca.gov/public/deliverable_documents/6382679581/Recorded%20LUC%2010%2D14%2D2010%2Epdf" target="6382679581">[VIEW COVENANT]</a> </font></td>"
How to solve this??
Ps. using Python 3 and Bs4