我正在使用BeautifulSoup和Requests抓取一些网站.我正在检查的页面中有一个数据位于<script language="JavaScript" type="text/javascript">标记内.它看起来像这样:
<script language="JavaScript" type="text/javascript">
var page_data = {
"default_sku" : "SKU12345",
"get_together" : {
"imageLargeURL" : "http://null.null/pictures/large.jpg",
"URL" : "http://null.null/index.tmpl",
"name" : "Paints",
"description" : "Here is a description and it works pretty well",
"canFavorite" : 1,
"id" : 1234,
"type" : 2,
"category" : "faded",
"imageThumbnailURL" : "http://null.null/small9.jpg"
......
Run Code Online (Sandbox Code Playgroud)
有没有办法可以page_data在此脚本标记中的变量中创建python字典或json对象?那会比使用BeautifulSoup获得价值更好.