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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:05:37+00:00 2026-05-16T20:05:37+00:00

I wrote a crawler in python, fetched urls has different types: it can be

  • 0

I wrote a crawler in python, fetched urls has different types: it can be url with html and url with image or big archives or other files. So i need fast determine this case to prevent of reading of big files such as big archives and continue crawling. How is the best way to determine url type at start of page loading?
i understand what i can do it by url name (end’s with .rar .jpg etc) but i think it’s not full solution. I need check header or something like that for this? also i need some page size predicition to prevent of large downloads. In other words set limit of downloaded page size, to prevent fast memory eating.

  • 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-16T20:05:38+00:00Added an answer on May 16, 2026 at 8:05 pm

    If you use a HTTP HEAD request on the resource, you will get relevant metadata on the resource without the resource data itself. Specifically, the content-length and content-type headers will be of interest.

    E.g.

    HEAD /stackoverflow/img/favicon.ico HTTP/1.1
    host: sstatic.net
    
    HTTP/1.1 200 OK
    Cache-Control: max-age=604800
    Content-Length: 1150
    Content-Type: image/x-icon
    Last-Modified: Mon, 02 Aug 2010 06:04:04 GMT
    Accept-Ranges: bytes
    ETag: "2187d82832cb1:0"
    X-Powered-By: ASP.NET
    Date: Sun, 12 Sep 2010 13:38:36 GMT
    

    You can do this in python using httplib:

    >>> import httplib
    >>> conn = httplib.HTTPConnection("sstatic.net")
    >>> conn.request("HEAD", "/stackoverflow/img/favicon.ico")
    >>> res = conn.getresponse()
    >>> print res.getheaders()
    [('content-length', '1150'), ('x-powered-by', 'ASP.NET'), ('accept-ranges', 'bytes'), ('last-modified', 'Mon, 02 Aug 2010 06:04:04 GMT'), ('etag', '"2187d82832cb1:0"'), ('cache-control', 'max-age=604800'), ('date', 'Sun, 12 Sep 2010 13:39:26 GMT'), ('content-type', 'image/x-icon')]
    

    This tells you it’s an image (image/* mime-type) of 1150 bytes. Enough information for you to decide if you want to fetch the full resource.

    Additionally, this header tells you the server accepts HTTP partial content request (accept-ranges header) which allows you to retrieve data in batches.

    You will get the same header information if you do a GET directly, but this will also start sending the resource data in the body of the response, something you want to avoid.

    If you want to learn more about HTTP headers and their meaning, you can use an online tool such as ‘Fetch’

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

Sidebar

Related Questions

I am writing a crawler/parser that should be able to process different types of
I'm using python to write a crawler, since I need to parse html so
I wrote a web crawler in Python 2.6 using the Bing API that searches
There is a task to write a crawler to crawl the webpage by python.
I wrote a C++ DLL and it has been compiled. It requires Visual C++
Was looking to write a little web crawler in python. I was starting to
I recently wrote a java crawler program that finds the video links in a
I use mechanize gem to crawl websites. I wrote a very simple, one-threaded crawler
What are the correct content-types for XML, HTML and XHTML documents? I need to
I'm trying to write a multithreaded web crawler. My main entry class has the

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.