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 1061961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:33:06+00:00 2026-05-16T18:33:06+00:00

I am trying to store the links that I scrape from a site in

  • 0

I am trying to store the links that I scrape from a site in a non binary tree. The links are laid out hierarchically (obviously). The question is how do I generate the tree ? I mean, how am I going to work my way through the pages provided by the link so that I know who is who’s child.

For now I can get the first and the second level of links, but have no idea how to go from here besides that I have to recursively have to build it and have a way to stop when I get to a leaf (which I have).

What I was thinking was something like (code in Python):

def buildTree(root):
for node in root.children:
    if <end condition here>:
        continue
    else:
        nodes = getNodes(urllib2.urlopen(node.url).read())
        node.addChildren(nodes)
        buildTree(node)

where root and nodes are a user defined Node class

  • 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-16T18:33:07+00:00Added an answer on May 16, 2026 at 6:33 pm

    Obviously, the links in a site are not a tree, but a graph. You should have a Page object, which is identified by a URL, and a Link object, which points from one page to another (and Page A can point to page B, while page B is pointing to Page A, making it a graph, instead of a tree).

    Scanning algorithm pseudo-code:

    process_page(current_page):
        for each link on the current_page: 
        if target_page is not already in your graph:
            create a Page object to represent target_page
            add it to to_be_scanned set
        add a link from current_page to target_page
    
    scan_website(start_page)
        create Page object for start_page
        to_be_scanned = set(start_page)
        while to_be_scanned is not empty:
            current_page = to_be_scanned.pop()
            process_page(current_page)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to store BitmapData from a MovieClip that is a PNG with transparency.
Just trying to make a button that links in ratings tab in app store
I'm trying to figure out a good way to be able to store plain
I'm trying to open all external links on a site in a new window.
I am trying to store the resulting list from ls -la into a variable
I'm trying to gather a list of hyperlinks (the url that it links to)
I am trying to extract .com, .net and .org links from a single webpage
Im trying to store a list,collection of data objects in Hbase. For example ,a
I am trying to store a byteArrayInputStream as File on a FTP Server .
I'm trying to store and retrieve numbers in android so later I can do

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.