Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1019315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:59:36+00:00 2026-05-16T10:59:36+00:00

I have such files to parse (from scrapping) with Python: some HTML and JS

  • 0

I have such files to parse (from scrapping) with Python:

some HTML and JS here...
SomeValue = 
{
     'calendar': [
     {       's0Date': new Date(2010, 9, 12),
             'values': [
                     { 's1Date': new Date(2010, 9, 17), 'price': 9900 },
                     { 's1Date': new Date(2010, 9, 18), 'price': 9900 },
                     { 's1Date': new Date(2010, 9, 19), 'price': 9900 },
                     { 's1Date': new Date(2010, 9, 20), 'price': 9900 },
                     { 's1Date': new Date(2010, 9, 21), 'price': 9900 },
                     { 's1Date': new Date(2010, 9, 22), 'price': 9900 },
                     { 's1Date': new Date(2010, 9, 23), 'price': 9900 }]
     },
     'data': [{
     index: 0,
     serviceClass: 'Economy',
     prices: [9900, 320.43, 253.27],
     eTicketing: true,
     segments: [{
             indexSegment: 0,
             stopsCount: 1,
             flights: [{
                     index: 0,

... and a lot of nested data and again HTML and JS...

I need to parse it and extract all json data. Now I use regex with cleaning all ‘\n’ and ‘\t’ and eval() function to convert it to Python dictionary.. I really don’t like this solution, eval() especially. But I looked at BeautifulSoup and lxml, and didn’t find something that will help to parse it.
Can you suggest something better than regex and eval() for this task?
Page example: http://codepaste.ru/3830/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:59:37+00:00Added an answer on May 16, 2026 at 10:59 am

    aarrghhh no regex dont use regex no regex no no nooooooo


    Use the json module to handle JSON data:

    import json
    json.loads( <string> )
    

    Use BeautifulSoup or lxml to handle parsing the html page:

    from BeautifulSoup import BeautifulSoup
    soup = BeautifulSoup( <string> )
    

    If you want specific help, you’ll need to provide specific data e.g. the class of the tags in which this data is enclosed. You could soup.findAll the script tags, for instance, then strip some lines to get to the JSON, then feed that into json.loads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since the default method for Ajax.Request is POST, the equivalent… May 16, 2026 at 3:25 pm
  • Editorial Team
    Editorial Team added an answer If you are expecting to use the value of i… May 16, 2026 at 3:25 pm
  • Editorial Team
    Editorial Team added an answer Something like the following should work, you may need to… May 16, 2026 at 3:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a python script which should parse a file and produce some output
I have a separate domain name for static content such as images, js files,
I have this scenario. OS is UNIX. There are a bunch of files on
I have IIS log with extra field 'foo'. #Fields: foo date s-sitename ... foo1
I am working with potentially huge XML files containing complex trace information from on
Hi I'm looking to parse spreadsheets (xls/ods) in Groovy. I have been using the
I am using Installshield, and have had success in launching my exe install files
I would like to parse the menu structure for Gnome Panels (the standard Gnome
My application requires me to store sets of bits along with some accompanying metadata
I got in every php project (around 25!), some sh scripts that help me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.