【发布时间】:2017-05-09 22:52:06
【问题描述】:
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
这是我在尝试访问传递所有值的句柄时遇到的确切错误。那里可以看到的 html 内容正是我需要的。我只复制了其中的几个部分,因为它是带有表格和行的大标签。我能够成功地将其加载到 Web 应用程序中,但在这里我正在使用 API。
不是 JSON 可序列化的
我正在抓取一个网站,并从该网站获取 html 表格内容并尝试通过我的 REST API 构建返回该内容,并使用 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}
考虑上面的代码,我已经成功地抓取了内容,并且在 marktable 变量中可用。现在我如何返回它以便在尝试使用特定句柄访问时可以访问它。我必须做什么才能使其可序列化,或者在 REST API 中返回此类内容的最佳方式是什么。
【问题讨论】:
标签: python json rest flask flask-restful