Absent<br>\r\n\t\t\tW - Withheld\r\n\t\t\t\r\n\t\t\t<b>Note:</b><br>\r\n\t\t\tThis Sheet is for general idea of marks you secured. This is not for official use. If any mistakes appear; record at NEB ledger will be referred.\r\n\t\t\r\n\r\n\t\t\r\n\t\t\r\n\r\n \t\t\r\n </br></br></br></br></br></td>\n</tr>\n</table> is not JSON serializable
This is the exact error I get when trying to access the handle passing all the values. The html content that can be seen there are what I exactly need.I have copied only few sections of it since it was large tags with table and rows. I was able to successfully to load this in web application but here I am working with API.
is not JSON serializable
I am scraping a site and from the site I am getting the html table content and trying to return that via my REST API build with flask-restful
marks=requests.post("somesitelinkhere",data=data_load2)
soup2=BeautifulSoup(marks.content,'html.parser')
#this is the heading to show what Result it is
headinghere=soup2.find('h2').text
markstable=soup2.find('table')
return {'marksheet':markstable}
Consider the above code I have successfully scraped the content and which in available in markstable variable.Now how do I return it so that it will be accessible when trying to access with the specific handle. What do I have to do to make it serializable or what is the best way to return such content in REST API.
markstable
is aBeautifulSoup.Tag
object. You can extract the content string from it usingmarkstable.contents
and send it over as the response.