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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:44:58+00:00 2026-06-04T15:44:58+00:00

I’m working on a crawler project. I’m stuck in a situation wherein the href

  • 0

I’m working on a crawler project. I’m stuck in a situation wherein the href text on a page keeps on repeating on other pages under that domain.
For example if the url is example.com then the href values on these pages are hrefList=[/hello/world,/aboutus,/blog,/contact].

So urls for these page would be
example.com/hello/world
example.com/aboutus
etc

Now on the page example.com/hello/world, the hrefList is again present. Hence I’ll get urls as
example.com/hello/world/hello/world,
example.com/hello/world/aboutus etc

Now out of these pages /hello/world/hello/world is a proper page with http status as 200 and this is going on happening recursively. Rest of the pages would have page not found and hence can be discarded

I’m getting list of new urls which are not correct urls. Is there any way to overcome this?

This is my codebase:

for url in allUrls:
    if url not in visitedUrls:
        visitedUrls.append(url)

        http=httplib2.Http()
        response,content=http.request(url,headers={'User-Agent':'Crawler-Project'})        
        if (response.status/100<4):
            soup=BeautifulSoup(content)
            links=soup.findAll('a',href=True)
            for link in links:
                if link.has_key('href'):
                    if len(link['href']) > 1:
                        if not any(x in link['href'] for x in ignoreUrls):
                            if link['href'][0]!="#":
                                if "http" in link["href"]:
                                    allUrls.append(link["href"])
                                else:
                                    if url[-1]=="/" and link['href'][0]=="/":
                                        allUrls.append(url+link['href'][1:])
                                    else:       
                                        if not (url[-1] =="/" or link['href'][0] =="/"): 
                                            allUrls.append(url+"/"+link['href'])
                                        else:
                                            allUrls.append(url+link['href'])
  • 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-04T15:45:01+00:00Added an answer on June 4, 2026 at 3:45 pm

    If we assume that the pages you get are the same, a possible workaround would be to create a hash of the page and make sure that you don’t crawl two pages with the same hash.

    What you hash will determine how robust and how resource-intensive this heuristic is. You could hash the whole webpage contents or some combination of its contents/headers and the links found by your crawler (or something else that would be unique enough per webpage other than its URL). Evidently, including the page’s URL is not a good idea as your problem right now is that those pages have different URLs but the same content (with invalid links)

    While you can, you shouldn’t have to implement a workaround for webpages that are not done correctly. That will be a neverending story.

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

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social

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.