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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:57:35+00:00 2026-05-14T20:57:35+00:00

I have a script that parses an html page for all the links within

  • 0

I have a script that parses an html page for all the links within it. I am getting all of them fine, but I have a list of domains I want to compare it against. So a sample list contains

list=['www.domain.com', 'sub.domain.com']

But I may have a list of links that look like

http://domain.com
http://sub.domain.com/some/other/page

I can strip off the http:// just fine, but in the two example links I just posted, they both should match. The first I would like to match against the http://www.domain.com, and the second, I would like to match against the subdomain in the list.

Right now I am using url2lib for parsing the html. What are my options in completely this task?

  • 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-14T20:57:36+00:00Added an answer on May 14, 2026 at 8:57 pm

    You might consider stripping ‘www.’ from the list and doing something as simple as:

    url = 'domain.com/'
    for domain in list:
        if url.startswith(domain):
            ... do something ...
    

    Or trying both wont hurt either I spose:

    url = 'domain.com/'
    for domain in list:
        domain_minus_www = domain
        if domain_minus_www.startswith('www.'):
            domain_minus_www = domain_minus_www[4:]
        if url.startswith(domain) or url.startswith(domain_minus_www):
            ... do something ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have a script that recursively loops through all the sub directories and compresses
I have following script that executes all the .reg files in the current directory.
I have a script that obtains information about the current folders and subfolders within
The script I am using 'gets' a html page and parses is showing only
I have a page that uses jQuery's $.post() method to get some html and
I have an html page that has particular text that I want to parse
I have a script which works fine on my old Windows XP computer but
I need to write a script that takes a link and parses the HTML
I have a script that parse the database and create php classes to work

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.