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

  • SEARCH
  • Home
  • 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 7895579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:40:39+00:00 2026-06-03T07:40:39+00:00

I am trying to parse an html page but I need to filter the

  • 0

I am trying to parse an html page but I need to filter the results before I parse the page.

For instance, ‘http://www.ksl.com/index.php?nid=443’ is a classified listing of cars in Utah. Instead of parsing ALL the cars, I’d like to filter it first (ie find all BMWs) and then only parse those pages. Is it possible to fill in a javascript form with python?

Here’s what I have so far:

import urllib

content = urllib.urlopen('http://www.ksl.com/index.php?nid=443').read()
f = open('/var/www/bmw.html',"w")
f.write(content)
f.close()
  • 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-06-03T07:40:40+00:00Added an answer on June 3, 2026 at 7:40 am

    Here is the way to do it. First download the page, scrape it to find the models that you are looking for, then you can get links to the new pages to scrape. There is no need for javascript here. This model and the BeautifulSoup documentation will get you going.

    from BeautifulSoup import BeautifulSoup
    import urllib2
    
    base_url = 'http://www.ksl.com'
    url = base_url + '/index.php?nid=443'
    model = "Honda" # this is the name of the model to look for
    
    # Load the page and process with BeautifulSoup
    handle = urllib2.urlopen(url)
    html = handle.read()
    soup = BeautifulSoup(html)
    
    # Collect all the ad detail boxes from the page
    divs = soup.findAll(attrs={"class" : "detailBox"})
    
    # For each ad, get the title
    # if it contains the word "Honda", get the link
    for div in divs:
        title = div.find(attrs={"class" : "adTitle"}).text
        if model in title:
            link = div.find(attrs={"class" : "listlink"})["href"]
            link = base_url + link
            # Now you have a link that you can download and scrape
            print title, link
        else:
            print "No match: ", title
    

    At the moment of answering, this code snippet is looking for Honda models and returns the following:

    1995-  Honda Prelude http://www.ksl.com/index.php?sid=0&nid=443&tab=list/view&ad=8817797
    No match:  1994-  Ford Escort
    No match:  2006-  Land Rover Range Rover Sport
    No match:  2006-  Nissan Maxima
    No match:  1957-  Volvo 544
    No match:  1996-  Subaru Legacy
    No match:  2005-  Mazda Mazda6
    No match:  1995-  Chevrolet Monte Carlo
    2002-  Honda Accord http://www.ksl.com/index.php?sid=0&nid=443&tab=list/view&ad=8817784
    No match:  2004-  Chevrolet Suburban (Chevrolet)
    1998-  Honda Civic http://www.ksl.com/index.php?sid=0&nid=443&tab=list/view&ad=8817779
    No match:  2004-  Nissan Titan
    2001-  Honda Accord http://www.ksl.com/index.php?sid=0&nid=443&tab=list/view&ad=8817770
    No match:  1999-  GMC Yukon
    No match:  2007-  Toyota Tacoma
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse some returned html (from http://www.google.com/movies?near=37130 )to look for currently playing
I'm currently trying to parse the html page http://84.19.184.204:8000/played.html using JS. But it's been
I am trying to parse this HTML page here with HTML Agility Pack, but
I am trying to parse an html page with BeautifulSoup, but it appears that
i'm trying to parse an html page with XPathDocument, but gives error 'cause the
I'm trying to parse some parts of an HTML page but I have problems
i'm trying to parse an html page and get the first occurrence of a
I am trying to use html5lib to parse an html page in to something
I am trying to parse an HTML table using Hpricot but am stuck, not
I'm trying to parse a HTML page where the majority of the content is

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.