折腾:
【记录】用PySpider去爬取scholastic的绘本书籍数据
期间,代码:
productMatch = re.search("^\s*product:\s*(?P<productJson>\{.+?\}$)", respText, re.S|re.M) print("productMatch=%s" % productMatch) if productMatch: productJson = productMatch.group("productJson") print("productJson=%s" % productJson) # productJson = productJson.replace("'", '"') productJsonFiltered = re.sub("^\s+(?P<keyName>\w+):", '"\g<keyName>":', productJson, flags=re.M) # productJsonFiltered = productJsonFiltered.replace("'", '"') productJsonFiltered = productJsonFiltered.replace("''", '""') print("productJsonFiltered=%s" % productJsonFiltered) productDict = json.loads(productJsonFiltered) print("productDict=%s" % productDict)
输出:
productJsonFiltered={ "productISBN": "9780688147327", "productionOption": "", "productTitle": "Chrysanthemum", "productDescription": "<p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she<\/i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you.<br \/><\/p><br \/><p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium<\/i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that<\/i> name is <i>Chrysanthemum<\/i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again.<br \/><\/p><br \/><p>In this award\u002Dwinning picture book, favorite author\/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.<\/p>", "productGrades": "K-2", "productURL": "/content/scholastic/books2/chrysanthemum-by-kevin-henkes", "productSubjects": "Bullying,Confidence and Self-Esteem,Elementary School,Individuality", "productAvailability": "true", "productImageThumbNail": " https://www.scholastic.com/content5/media/products/58/9780590135658_xlg.jpg", "productCoverImage": " https://www.scholastic.com/content5/media/products/58/9780590135658_mres.jpg", "productFormat": "Paperback Book", "productListPrice": "$6.50", "productListPriceRaw": "6.50", "productSeriesNumber": "", "productSeriesName": "", "productContributorDetails": "Kevin Henkes|Illustrated By|/content/scholastic/contributors/kevin-henkes~Kevin Henkes|Author|/content/scholastic/contributors/kevin-henkes", "productAvailabilityText": "From the Teacher Store", "productCartButtonText": "Add to Cart", "productInventory": "77.0", "productReadingLevel": "Guided Reading:M | LEXILE MEASURE:570L | Grade Level Equivalent:N/A | DRA:24", "productGuidedReadingLevel": "M", "productEnglishLexileLevel": "570L", "productGradeLevelEquivalent": "N/A", "productDRALevel": "24", "productSalePrice": "$6.50", "productSalePriceRaw": "6.50" } [E 181011 16:32:09 base_handler:203] Invalid \escape: line 5 column 179 (char 269) Traceback (most recent call last): File "/Users/crifan/.local/share/virtualenvs/crawler_scholastic_storybook-ttmbK5Yf/lib/python3.6/site-packages/pyspider/libs/base_handler.py", line 196, in run_task result = self._run_task(task, response) File "/Users/crifan/.local/share/virtualenvs/crawler_scholastic_storybook-ttmbK5Yf/lib/python3.6/site-packages/pyspider/libs/base_handler.py", line 176, in _run_task return self._run_func(function, response, task) File "/Users/crifan/.local/share/virtualenvs/crawler_scholastic_storybook-ttmbK5Yf/lib/python3.6/site-packages/pyspider/libs/base_handler.py", line 155, in _run_func ret = function(*arguments[:len(args) - 1]) File "<ScholasticStorybook>", line 118, in singleBookCallback File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 355, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Invalid \escape: line 5 column 179 (char 269)
即:
对于:
"productDescription": "<p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she<\/i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you.<br \/><\/p><br \/><p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium<\/i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that<\/i> name is <i>Chrysanthemum<\/i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again.<br \/><\/p><br \/><p>In this award\u002Dwinning picture book, favorite author\/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.<\/p>",
去json解码出错了。
其中column 179好像是:\x27
python json loads json.decoder.JSONDecodeError: Invalid \escape
试试:
productDict = json.loads(productJsonFiltered, strict=False)
结果问题依旧。
去试试encoding
productDict = json.loads(productJsonFiltered, strict=False, encoding="utf-8")
结果问题依旧。
考虑到此处的字符串中,除了:
\x27
还有其他特殊的:
- \u002
- \x26quot;
等特殊字符
-》所以还是想另外办法:
先去把productDescription的字符串的值,抽取出来,再去json.loads
然后对于提取出的productDescription的值,再去html解析,比如送到bs4中看看能否正常解析
此时,可以用代码:
productMatch = re.search("^\s*product:\s*(?P<productJson>\{.+?\}$)", respText, re.S|re.M) print("productMatch=%s" % productMatch) if productMatch: productJson = productMatch.group("productJson") print("productJson=%s" % productJson) # productJson = productJson.replace("'", '"') productJsonFiltered = re.sub("^\s+(?P<keyName>\w+):", '"\g<keyName>":', productJson, flags=re.M) # productJsonFiltered = productJsonFiltered.replace("'", '"') productJsonFiltered = productJsonFiltered.replace("''", '""') print("productJsonFiltered=%s" % productJsonFiltered) descriptionValueMatch = re.search('"productDescription":\s*"(?P<descriptionValue>.+?)",', productJsonFiltered) print("descriptionValueMatch=%s" % descriptionValueMatch) if descriptionValueMatch: descriptionValue = descriptionValueMatch.group("descriptionValue") print("descriptionValue=%s" % descriptionValue) descriptionValueFiltered = descriptionValue.replace("\/", "/") print("descriptionValueFiltered=%s" % descriptionValueFiltered) description = htmlToString(descriptionValueFiltered) print("description=%s" % description) productJsonFiltered = productJsonFiltered.replace(descriptionValue, "") print("productJsonFiltered=%s" % productJsonFiltered) # productDict = json.loads(productJsonFiltered) # productDict = json.loads(productJsonFiltered, strict=False) productDict = json.loads(productJsonFiltered, strict=False, encoding="utf-8") print("productDict=%s" % productDict)
基本上得到我们要的dict对象,以及包含html的entity的了:
productMatch=<_sre.SRE_Match object; span=(3785, 6783), match=' product: {\n productISBN: "978068814> productJson={ productISBN: "9780688147327", productionOption: '', productTitle: "Chrysanthemum", productDescription: "<p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she<\/i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you.<br \/><\/p><br \/><p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium<\/i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that<\/i> name is <i>Chrysanthemum<\/i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again.<br \/><\/p><br \/><p>In this award\u002Dwinning picture book, favorite author\/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.<\/p>", productGrades: "K-2", productURL: "/content/scholastic/books2/chrysanthemum-by-kevin-henkes", productSubjects: "Bullying,Confidence and Self-Esteem,Elementary School,Individuality", productAvailability: "true", productImageThumbNail: " https://www.scholastic.com/content5/media/products/58/9780590135658_xlg.jpg", productCoverImage: " https://www.scholastic.com/content5/media/products/58/9780590135658_mres.jpg", productFormat: "Paperback Book", productListPrice: "$6.50", productListPriceRaw: "6.50", productSeriesNumber: "", productSeriesName: "", productContributorDetails: "Kevin Henkes|Illustrated By|/content/scholastic/contributors/kevin-henkes~Kevin Henkes|Author|/content/scholastic/contributors/kevin-henkes", productAvailabilityText: "From the Teacher Store", productCartButtonText: "Add to Cart", productInventory: "77.0", productReadingLevel: "Guided Reading:M | LEXILE MEASURE:570L | Grade Level Equivalent:N/A | DRA:24", productGuidedReadingLevel: "M", productEnglishLexileLevel: "570L", productGradeLevelEquivalent: "N/A", productDRALevel: "24", productSalePrice: "$6.50", productSalePriceRaw: "6.50" } productJsonFiltered={ "productISBN": "9780688147327", "productionOption": "", "productTitle": "Chrysanthemum", "productDescription": "<p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she<\/i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you.<br \/><\/p><br \/><p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium<\/i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that<\/i> name is <i>Chrysanthemum<\/i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again.<br \/><\/p><br \/><p>In this award\u002Dwinning picture book, favorite author\/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.<\/p>", "productGrades": "K-2", "productURL": "/content/scholastic/books2/chrysanthemum-by-kevin-henkes", "productSubjects": "Bullying,Confidence and Self-Esteem,Elementary School,Individuality", "productAvailability": "true", "productImageThumbNail": " https://www.scholastic.com/content5/media/products/58/9780590135658_xlg.jpg", "productCoverImage": " https://www.scholastic.com/content5/media/products/58/9780590135658_mres.jpg", "productFormat": "Paperback Book", "productListPrice": "$6.50", "productListPriceRaw": "6.50", "productSeriesNumber": "", "productSeriesName": "", "productContributorDetails": "Kevin Henkes|Illustrated By|/content/scholastic/contributors/kevin-henkes~Kevin Henkes|Author|/content/scholastic/contributors/kevin-henkes", "productAvailabilityText": "From the Teacher Store", "productCartButtonText": "Add to Cart", "productInventory": "77.0", "productReadingLevel": "Guided Reading:M | LEXILE MEASURE:570L | Grade Level Equivalent:N/A | DRA:24", "productGuidedReadingLevel": "M", "productEnglishLexileLevel": "570L", "productGradeLevelEquivalent": "N/A", "productDRALevel": "24", "productSalePrice": "$6.50", "productSalePriceRaw": "6.50" } descriptionValueMatch=<_sre.SRE_Match object; span=(91, 1657), match='"productDescription": "<p>Chrysanthemum loves her> descriptionValue=<p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she<\/i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you.<br \/><\/p><br \/><p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium<\/i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that<\/i> name is <i>Chrysanthemum<\/i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again.<br \/><\/p><br \/><p>In this award\u002Dwinning picture book, favorite author\/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.<\/p> descriptionValueFiltered=<p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she</i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you.<br /></p><br /><p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium</i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that</i> name is <i>Chrysanthemum</i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again.<br /></p><br /><p>In this award\u002Dwinning picture book, favorite author/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.</p> htmlText=<p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she</i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you. </p> <p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium</i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that</i> name is <i>Chrysanthemum</i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again. </p> <p>In this award\u002Dwinning picture book, favorite author/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.</p> soup=<html><body><p>Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that <i>she</i> was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you. </p> <p>Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. <i>Delphinium</i> Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that <i>that</i> name is <i>Chrysanthemum</i>, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again. </p> <p>In this award\u002Dwinning picture book, favorite author/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom.</p></body></html> pureText=Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that she was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you. Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. Delphinium Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that that name is Chrysanthemum, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again. In this award\u002Dwinning picture book, favorite author/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom. description=Chrysanthemum loves her name — until she starts kindergarten, which is an unfamiliar world full of short names like Sue, Bill, Max, Sam, and Joe. But it\x27s Victoria who really makes Chrysanthemum wilt, offering that she was named after her grandmother, which is much more important than being named after a flower. Though Chrysanthemum\x27s parents try to soothe her wounded soul with \x26quot;hugs, kisses, and Parcheesi,\x26quot; it\x27s not easy to find solace (and regain lost self\u002Desteem) with all the girls on the playground threatening to \x26quot;pluck\x26quot; and \x26quot;smell\x26quot; you. Then the children meet their music teacher, charismatic Mrs. Twinkle. Mrs. Delphinium Twinkle, that is. When Mrs. Twinkle announces that she wants to name her baby the prettiest name she has ever heard, and that that name is Chrysanthemum, all the kids wish they had flower names, too. For her part, Chrysanthemum blooms once again. In this award\u002Dwinning picture book, favorite author/illustrator Henkes once again demonstrates his talent for capturing the difficult dramas of childhood in simple text and cartoon\u002Dlike illustrations. His mouse characters, depicted in energetic pen\u002Dand\u002Dink and watercolor pictures, have all the depth and dimension of real kids (and parents). Especially appropriate for any child with a difficult or unusual name, this perceptive picture book will charm a wider audience with its wit and wisdom. productJsonFiltered={ "productISBN": "9780688147327", "productionOption": "", "productTitle": "Chrysanthemum", "productDescription": "", "productGrades": "K-2", "productURL": "/content/scholastic/books2/chrysanthemum-by-kevin-henkes", "productSubjects": "Bullying,Confidence and Self-Esteem,Elementary School,Individuality", "productAvailability": "true", "productImageThumbNail": " https://www.scholastic.com/content5/media/products/58/9780590135658_xlg.jpg", "productCoverImage": " https://www.scholastic.com/content5/media/products/58/9780590135658_mres.jpg", "productFormat": "Paperback Book", "productListPrice": "$6.50", "productListPriceRaw": "6.50", "productSeriesNumber": "", "productSeriesName": "", "productContributorDetails": "Kevin Henkes|Illustrated By|/content/scholastic/contributors/kevin-henkes~Kevin Henkes|Author|/content/scholastic/contributors/kevin-henkes", "productAvailabilityText": "From the Teacher Store", "productCartButtonText": "Add to Cart", "productInventory": "77.0", "productReadingLevel": "Guided Reading:M | LEXILE MEASURE:570L | Grade Level Equivalent:N/A | DRA:24", "productGuidedReadingLevel": "M", "productEnglishLexileLevel": "570L", "productGradeLevelEquivalent": "N/A", "productDRALevel": "24", "productSalePrice": "$6.50", "productSalePriceRaw": "6.50" } productDict={'productISBN': '9780688147327', 'productionOption': '', 'productTitle': 'Chrysanthemum', 'productDescription': '', 'productGrades': 'K-2', 'productURL': '/content/scholastic/books2/chrysanthemum-by-kevin-henkes', 'productSubjects': 'Bullying,Confidence and Self-Esteem,Elementary School,Individuality', 'productAvailability': 'true', 'productImageThumbNail': ' https://www.scholastic.com/content5/media/products/58/9780590135658_xlg.jpg', 'productCoverImage': ' https://www.scholastic.com/content5/media/products/58/9780590135658_mres.jpg', 'productFormat': 'Paperback Book', 'productListPrice': '$6.50', 'productListPriceRaw': '6.50', 'productSeriesNumber': '', 'productSeriesName': '', 'productContributorDetails': 'Kevin Henkes|Illustrated By|/content/scholastic/contributors/kevin-henkes~Kevin Henkes|Author|/content/scholastic/contributors/kevin-henkes', 'productAvailabilityText': 'From the Teacher Store', 'productCartButtonText': 'Add to Cart', 'productInventory': '77.0', 'productReadingLevel': 'Guided Reading:M | LEXILE MEASURE:570L | Grade Level Equivalent:N/A | DRA:24', 'productGuidedReadingLevel': 'M', 'productEnglishLexileLevel': '570L', 'productGradeLevelEquivalent': 'N/A', 'productDRALevel': '24', 'productSalePrice': '$6.50', 'productSalePriceRaw': '6.50'}
所以接着就是:
【已解决】PySpider中把一段html的字符串去除entity和unicode escape转义
转载请注明:在路上 » 【已解决】PySpider用json.loads字符串出错:json.decoder.JSONDecodeError: Invalid \escape: line 5 column 179 (char 269)