Skip to content
Advertisement

scrapy/regex get json_object from html

I’m crawling reviews from a website in scrapy python and want to get all the reviews from the following part of the raw html as a dictionary. Getting the window.cj.listings is no problem, but I can’t seem to get the window.cj.app_data out with regex. The following code works for getting the listing.

    pattern = r'window.cj.listings*=s*({.*?})s*;s*n'
    json_data = response.css('script::text').re_first(pattern)
    data = json.loads(json_data)

But I get nothing from window.cj.app_data, when I change the code to the following:

    pattern = r'window.cj.app_datas*=s*({.*?})s*;'
    json_data = response.css('script::text').re_first(pattern)
    data = json.loads(json_data)

this is the part of the scraped html

<script>
        window.cj.app_data = {
            user: {},
            reviews: {"access_token": null, "average_rating": 4.57047, "five_stars": 0.8189655172413793, "four_stars": 0.06896551724137931, "is_customer": false, "is_individual": false, "is_preview": false, "listing_id": 32208256, "listing_name": "Faithbox", "listing_review_images": [], "most_recent_review": null, "one_star": 0.0603448275862069, "slug": "faithbox", "testimonials": [{"author": {"email": "69dfac11ccf1c30ebc8eec2fa2577642", "id": 2526165300, "name": "Juliana J.", "subscription_length": "12 days", "total_helpful_votes": 61, "total_images": 57, "total_reviews": 103}, "author_is_current_customer": false, "body": "I love this box! In particular I really like the little u201cguideu201d that goes along with it with daily readings for the month. It keeps you on track and does it in an easy way! Love it! ", "created_at": "2020-07-01T15:14:15Z", "created_at_ago": "Jul 01, 2020", "curation": 5, "date": "Jul 01, 2020", "id": 3018924746, "images": [{"alt_text": null, "high_res_url": "//d17qo5cceyilur.cloudfront.net/QxltOkqgSzWzvBolgYC0_D7EFC2AB-8801-4B98-905E-BF2A58131D7B.jpg", "id": 3018923347, "low_res_url": "//d17qo5cceyilur.cloudfront.net/AOsU2w9iTvu9OGiA4FNp_D7EFC2AB-8801-4B98-905E-BF2A58131D7B.jpg", "rank": 0, "thumbnail_url": "//d17qo5cceyilur.cloudfront.net/xz25qn4gSVqa5u1vcBnb_D7EFC2AB-8801-4B98-905E-BF2A58131D7B.jpg"}], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Juliana J.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Great!! ", "updated_at": "2020-07-01T21:59:25Z", "updated_at_ago": "Jul 01, 2020", "verified": true, "votes": 1}, {"author": {"email": "17f227af4c3abcf8b9c3b1bd9b30bc07", "id": 2901753045, "name": "Roxanne E.", "subscription_length": "29 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "Love these boxes. They help me plan our daily talks and our longer Sunday discussions. ", "created_at": "2020-06-04T19:44:40Z", "created_at_ago": "Jun 04, 2020", "curation": 5, "date": "Jun 04, 2020", "id": 2964056033, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Roxanne E.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "My special God plans", "updated_at": "2020-06-04T19:44:40Z", "updated_at_ago": "Jun 04, 2020", "verified": true, "votes": 1}, {"author": {"email": "1e9574851f8dec4598467debe09490c2", "id": 2927166866, "name": "Nicole C.", "subscription_length": "17 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "Absolutely love Faithbox!! ", "created_at": "2020-06-04T00:11:57Z", "created_at_ago": "Jun 04, 2020", "curation": 5, "date": "Jun 04, 2020", "id": 2962446795, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Nicole C.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 2, "status": "live", "title": "Faithbox Subscription ", "updated_at": "2020-06-04T00:11:57Z", "updated_at_ago": "Jun 04, 2020", "verified": true, "votes": 1}, {"author": {"email": "bdb55e2cea9f087060f745329bddcc1d", "id": 2864318874, "name": "Diane H.", "subscription_length": "1 month", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "My parents got me a subscription as a gift and it couldnu0027t have come at a more perfect time.  I am looking forward to more boxes in the future.", "created_at": "2020-05-31T12:55:31Z", "created_at_ago": "May 31, 2020", "curation": 5, "date": "May 31, 2020", "id": 2953390084, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Diane H.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Perfect gift", "updated_at": "2020-05-31T12:55:31Z", "updated_at_ago": "May 31, 2020", "verified": true, "votes": 1}, {"author": {"email": "99299f1a2821dd376493e22f2870aa17", "id": 2849854342, "name": "Danielle P.", "subscription_length": "2 months", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "My daughter loves everything that comes in the box. The items are great quality items. We are happy with the subscription.", "created_at": "2020-05-30T16:46:24Z", "created_at_ago": "May 30, 2020", "curation": 5, "date": "May 30, 2020", "id": 2951778070, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Danielle P.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Great box!", "updated_at": "2020-05-30T16:46:24Z", "updated_at_ago": "May 30, 2020", "verified": true, "votes": 1}, {"author": {"email": "5a063426da9f5f09cd15aac850f31025", "id": 2891874891, "name": "Taylor M.", "subscription_length": "27 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "A great way to grow with God. Lots of options for purchasing and easy to sign up. Faithbox is much better than other boxes because it helps grow you as a person. ", "created_at": "2020-05-29T02:10:16Z", "created_at_ago": "May 29, 2020", "curation": 5, "date": "May 29, 2020", "id": 2948266668, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Taylor M.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Grow with God - worth the $$", "updated_at": "2020-05-29T02:10:16Z", "updated_at_ago": "May 29, 2020", "verified": true, "votes": 1}, {"author": {"email": "d411acdd7d86166094c0b9284adc5787", "id": 2842603199, "name": "Amber D.", "subscription_length": "2 months", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I have to say I love Faithbox.  Not only do I love the items that come in the box I also the the daily devotional and the daily reading of my devotional with The Faithbox team!!!  Love love love it!!!! ", "created_at": "2020-05-29T01:41:08Z", "created_at_ago": "May 29, 2020", "curation": 5, "date": "May 29, 2020", "id": 2948229628, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Amber D.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "I love Faithbox ", "updated_at": "2020-05-29T01:41:08Z", "updated_at_ago": "May 29, 2020", "verified": true, "votes": 1}, {"author": {"email": "e471e436d5d01e506658593c117c84b8", "id": 2864725203, "name": "Brandee O.", "subscription_length": "1 month", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I received my first box in May and really enjoyed it! I would recommend this over other subscription boxes. I love the surprise:)", "created_at": "2020-05-29T01:28:02Z", "created_at_ago": "May 29, 2020", "curation": 5, "date": "May 29, 2020", "id": 2948212970, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Brandee O.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 4, "status": "live", "title": "NEW TO FAITHBOX", "updated_at": "2020-05-29T01:28:02Z", "updated_at_ago": "May 29, 2020", "verified": true, "votes": 1}, {"author": {"email": "9af831978f71051f3d1a4219ccf5b2c2", "id": 2842004402, "name": "Michelle R.", "subscription_length": "2 months", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I am new subscriber and felt like I needed a boost during the quarantine, and Faithbox really hit the spot with their products, app, and daily devotional. It is the boost I needed and I canu2019t wait to see what next month brings me. ", "created_at": "2020-05-28T21:01:34Z", "created_at_ago": "May 28, 2020", "curation": 5, "date": "May 28, 2020", "id": 2947854046, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Michelle R.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "A great product that inspires", "updated_at": "2020-05-28T21:01:34Z", "updated_at_ago": "May 28, 2020", "verified": true, "votes": 1}, {"author": {"email": "5a290442942e3066eb0adbce82810630", "id": 2934912702, "name": "Beth D.", "subscription_length": "7 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "Looking forward to receiving my box!! I love the idea and I love that I will be able to dive deeper into my studies of The Word with this box", "created_at": "2020-05-28T19:33:21Z", "created_at_ago": "May 28, 2020", "curation": 5, "date": "May 28, 2020", "id": 2947718647, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Beth D.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Love", "updated_at": "2020-05-28T19:33:21Z", "updated_at_ago": "May 28, 2020", "verified": true, "votes": 1}, {"author": {"email": "ea2d208f8f7bb3ffe9116c8e7a8c6a71", "id": 2858001504, "name": "Courtney K.", "subscription_length": "1 month", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I joined about 2 months ago and I am loving it! The daily devotionals and products in the boxes are amazing!! ", "created_at": "2020-05-28T18:48:54Z", "created_at_ago": "May 28, 2020", "curation": 5, "date": "May 28, 2020", "id": 2947653936, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Courtney K.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Love it!!", "updated_at": "2020-05-28T18:48:54Z", "updated_at_ago": "May 28, 2020", "verified": true, "votes": 1}, {"author": {"email": "755cefa1e9c41563fcc5f263c59cbbe5", "id": 2836291689, "name": "Amanda T.", "subscription_length": "2 months", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "Iu2019ve really enjoyed receding my Faithbox subscription boxes. I also purchased 3 boxes individually for Motheru2019s Day and they were awesome! This is a great way to keep the excitement of studying Godu2019s word going strong! ", "created_at": "2020-05-28T18:43:50Z", "created_at_ago": "May 28, 2020", "curation": 5, "date": "May 28, 2020", "id": 2947647469, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Amanda T.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Exciting and Great Gift", "updated_at": "2020-05-28T18:43:50Z", "updated_at_ago": "May 28, 2020", "verified": true, "votes": 1}, {"author": {"email": "fe43a7443d92a1072c314b82037eb586", "id": 2856904582, "name": "Joanna B.", "subscription_length": "1 month", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I love faithbox I have only gotten one box so far and my second one is on the way. My faith dwindles sometimes and it gets hard to just open and read my bible so the little devotionals and reading stuff really helps", "created_at": "2020-05-28T18:06:47Z", "created_at_ago": "May 28, 2020", "curation": 5, "date": "May 28, 2020", "id": 2947589768, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Joanna B.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "LOVE IT", "updated_at": "2020-05-28T18:06:47Z", "updated_at_ago": "May 28, 2020", "verified": true, "votes": 1}, {"author": {"email": "cdcbf5c34328759efda66cf938c70c1d", "id": 1997191161, "name": "Amber H.", "subscription_length": "1 month", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 2}, "author_is_current_customer": false, "body": "I really enjoy Faithbox! Especially right now when my bible study group is not able to meet in person (due to COVID-19). There were a few items that I wouldnu0027t use (like stickers), but my sister (who is 16) really liked them and it was great to be able to share things with her! ", "created_at": "2020-05-28T18:04:20Z", "created_at_ago": "May 28, 2020", "curation": 5, "date": "May 28, 2020", "id": 2947586579, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Amber H.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Great, especially right now during COVID", "updated_at": "2020-05-28T18:04:20Z", "updated_at_ago": "May 28, 2020", "verified": true, "votes": 1}, {"author": {"email": "fa430f3db521967928cb374f12d9e510", "id": 2792235492, "name": "Debrena S.", "subscription_length": "3 months", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I have recently wanted to grow in my faith and had came across faithbox so I ordered! I absolutely love it! I find myself everyday diving in the Word. I just need a little motivation and faithbox gave me that! Sometimes I feel like the months theme was not met for me, but it definitely helps to understand what others might be going through and it helps me be able to help them. I will continue to look forward to receiving these boxes as I grow in faith. ud83eudd70", "created_at": "2020-05-28T17:00:11Z", "created_at_ago": "May 28, 2020", "curation": 5, "date": "May 28, 2020", "id": 2947491474, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Debrena S.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Just want I needed! ", "updated_at": "2020-05-28T17:00:11Z", "updated_at_ago": "May 28, 2020", "verified": true, "votes": 1}, {"author": {"email": "352171b89f9974d9fea176d07b1e51e5", "id": 2875569518, "name": "Amanda A.", "subscription_length": "1 month", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "May 2020 was my first Faith Box. Let me tell you it was just what I needed! In a time of so much uncertainty, it has brought me so much joy and peace. Truly priceless - Thank you. ", "created_at": "2020-05-27T22:05:11Z", "created_at_ago": "May 27, 2020", "curation": 5, "date": "May 27, 2020", "id": 2945952027, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Amanda A.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Just what I needed. ", "updated_at": "2020-05-27T22:05:11Z", "updated_at_ago": "May 27, 2020", "verified": true, "votes": 1}, {"author": {"email": "4dffa2dbcf8eb31c55ee80853226052b", "id": 2878949597, "name": "Hannah D.", "subscription_length": "28 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I got the mobile subscription as I plan to travel and wont be home much so they send me emails everyday with a devotion and video as well as an ebook to read over the month. I really enjoy how they have a new theme each month and I was also surprised to see how welcoming and encouraging they are! I also really love how the devotionals and videos are short but powerful and meaningful. I have Lyme disease so its difficult for me to focus or read something for too long without getting symptoms so the short devotion is perfect for me and on my good days I will read the book as well so this has really helped me grow in my faith!", "created_at": "2020-05-25T21:15:49Z", "created_at_ago": "May 25, 2020", "curation": 5, "date": "May 25, 2020", "id": 2942001924, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Hannah D.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Loving this!", "updated_at": "2020-05-25T21:15:49Z", "updated_at_ago": "May 25, 2020", "verified": true, "votes": 1}, {"author": {"email": "68ad1c2415a3a50e86cfa6171108bfba", "id": 2855507787, "name": "Victoria D.", "subscription_length": "1 month", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "This box is amazing and inspirational, Iu2019ve only had one other subscription box in my life and now this is my only one lol I love the community, all the wonderful things they do, and that they have a kids version, I actually signed my baby up for the HelloBible box so we can do even more stuff together! Love it!", "created_at": "2020-05-25T18:12:46Z", "created_at_ago": "May 25, 2020", "curation": 5, "date": "May 25, 2020", "id": 2941759468, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Victoria D.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Amazing!!!", "updated_at": "2020-05-25T18:12:46Z", "updated_at_ago": "May 25, 2020", "verified": true, "votes": 1}, {"author": {"email": "65205a0b27fc47e9b4c7df7ffee2df4d", "id": 2709883697, "name": "Caryl S.", "subscription_length": "24 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I loved my first Faithbox and it came at exactly the right time I needed inspiration. Loved everything contained from the inspirational quotes on beautiful card stock worthy of framing. The flame less candle is a constant reminder that God is Good!  I will definitely be finding time to read the book enclosed. Well done Faithbox!!!! I look forward to next monthu2019s delivery!  Be blessed and continue spreading Faith!  ", "created_at": "2020-05-25T17:49:45Z", "created_at_ago": "May 25, 2020", "curation": 5, "date": "May 25, 2020", "id": 2941727086, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Caryl S.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": null, "status": "live", "title": "Awesome First Faithbox ", "updated_at": "2020-05-25T17:49:45Z", "updated_at_ago": "May 25, 2020", "verified": true, "votes": 1}, {"author": {"email": "37fa8bdadf049668bf89e9ca58079eda", "id": 2839190355, "name": "Katie B.", "subscription_length": "2 months", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "Absolutely love faithbox, I get emails each day for the daily devotion which gives me some kind of accountability and I love the verses and different books I receive each month. ", "created_at": "2020-05-25T14:50:22Z", "created_at_ago": "May 25, 2020", "curation": 5, "date": "May 25, 2020", "id": 2941490298, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Katie B.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Great", "updated_at": "2020-05-25T14:50:22Z", "updated_at_ago": "May 25, 2020", "verified": true, "votes": 1}, {"author": {"email": "9a314ca1afea3b573c300fd37e13558e", "id": 2902133213, "name": "Jennifer R.", "subscription_length": "19 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "Iu2019m loving my first Faithbox ", "created_at": "2020-05-25T14:45:17Z", "created_at_ago": "May 25, 2020", "curation": 5, "date": "May 25, 2020", "id": 2941484858, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Jennifer R.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "First box", "updated_at": "2020-05-25T14:45:17Z", "updated_at_ago": "May 25, 2020", "verified": true, "votes": 1}, {"author": {"email": "4367d05d2a79943aa478c831c9fc2ef2", "id": 2930558730, "name": "Kelli S.", "subscription_length": "5 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I was thrilled when I opened my first box.  Can not wait for the next one!", "created_at": "2020-05-25T14:28:35Z", "created_at_ago": "May 25, 2020", "curation": 5, "date": "May 25, 2020", "id": 2941465896, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Kelli S.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Very Happy", "updated_at": "2020-05-25T14:28:35Z", "updated_at_ago": "May 25, 2020", "verified": true, "votes": 1}, {"author": {"email": "bc301b2d8c3f5c0bfbecfb0cb418ed52", "id": 2289883284, "name": "Kayce S.", "subscription_length": "12 days", "total_helpful_votes": 1, "total_images": 3, "total_reviews": 3}, "author_is_current_customer": false, "body": "I absolutely love this box! I appreciate how they support different charities and businesses who help individuals in need, like single mothers in Uganda! I was so touched by everything in my box and was overwhelmed with tears. I am so glad I have subscribed to this and look forward to reading the book I received as well as the day-to-day booklet. Thank you for making this such a wonderful Opportunity to serve and be served. ", "created_at": "2020-08-05T03:44:41Z", "created_at_ago": "Aug 05, 2020", "curation": 5, "date": "Aug 05, 2020", "id": 3089955475, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Kayce S.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 5, "status": "live", "title": "Blown Away", "updated_at": "2020-08-05T03:44:41Z", "updated_at_ago": "Aug 05, 2020", "verified": true, "votes": 0}, {"author": {"email": "daa231b8ac082059dc335eb3a15a7e7d", "id": 607539985, "name": "Lori H.", "subscription_length": "26 days", "total_helpful_votes": 0, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "Shipping took a long time but it was during riots so that could have been the hold up.  The box did not disappoint.  I loved every piece I received and the book was from my favorite author.  My favorite part is the daily devotional!", "created_at": "2020-06-18T13:24:32Z", "created_at_ago": "Jun 18, 2020", "curation": 5, "date": "Jun 18, 2020", "id": 2992075881, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Lori H.", "product_id": null, "quality": 5, "rating": 5, "response": null, "response_date": null, "response_name": null, "shipping": 1, "status": "live", "title": "Pleasantly Pleased", "updated_at": "2020-06-18T13:24:32Z", "updated_at_ago": "Jun 18, 2020", "verified": true, "votes": 0}, {"author": {"email": "4da48895a1b6083367751a96be1ec530", "id": 2922961979, "name": "Glover C.", "subscription_length": "14 days", "total_helpful_votes": 1, "total_images": 0, "total_reviews": 1}, "author_is_current_customer": false, "body": "I have not received my Faithbox as I ordered mid month. However, I placed an order on the family and devotionals, along with a book, and coffee mug and they were shipped really fast. I am in so in love with these other products that the anticipation of my 1st Faithbox is so exciting. Lastly, although I  didnu0027t get Mayu0027s Faithbox I have been able to follow along with the daily devotionals through the app.", "created_at": "2020-05-30T17:23:24Z", "created_at_ago": "May 30, 2020", "curation": 5, "date": "May 30, 2020", "id": 2951838400, "images": [], "listing": {"current_version_id": 3184662645, "id": 32208256, "name": "Faithbox"}, "name": "Glover C.", "product_id": null, "quality": 5, "rating": 4, "response": null, "response_date": null, "response_name": null, "shipping": 4, "status": "live", "title": "Love", "updated_at": "2020-05-30T17:23:24Z", "updated_at_ago": "May 30, 2020", "verified": true, "votes": 1}], "three_stars": 0.0, "total_reviews": 116, "two_stars": 0.05172413793103448},
            listing: {"verbose_freq": "Monthly"};
        window.cj.listing = {'shortened_example': 123};
    </script>

Advertisement

Answer

You are using .*? in regex, which is not a “multiline” match. I have played with it a little here – Regex101 and the working match for multiline everything inside {} is [Ss]*

so the full regex would look like: pattern = r'window.cj.app_datas*=s*({[Ss]*})'

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement