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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:37:15+00:00 2026-06-05T06:37:15+00:00

I have looked through similar questions in stackoverflow yet seemingly no answers measures up.

  • 0

I have looked through similar questions in stackoverflow yet seemingly no answers measures up. Now I have a cookies.txt in hands which is exported by a chrome extension named “cookies.txt”. I can execute a command “wget –load-cookies cookies.txt http://www.example.com” to download the webpage with the account authenticated.

However, I met a problem when I tried to use this file in my python script as follows,

import mechanize

cookie = 'cookies.txt'

cookiejar = mechanize.FileCookieJar(cookies.txt)

br = mechanize.Browser()

br.set_handle_robots(False)

br.set_cookiejar(cookiejar)

url = 'www.example.com'
response = br.open(url)
s = response.read()

f = open('test.html','w')
f.write(s)
f.close()

I only got a webpage without my account logged in after executing this script. And If I change the first several lines of code into this

import mechanize

cookie = 'cookies.txt'
cookiejar = mechanize.MozillaCookieJar()
cookiejar.load(cookie)

I got an error message “mechanize._clientcookie.LoadError: cookies.txt does not look like a Netscape format cookies file” executing the script.

I have no idea how I can get the authentication done with this cookies.txt given that this file works in wget command.

  • 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-05T06:37:16+00:00Added an answer on June 5, 2026 at 6:37 am

    I was getting the same error until I added this to the top of my cookie file, and now works.

    # Netscape HTTP Cookie File
    # http://www.netscape.com/newsref/std/cookie_spec.html
    # This is a generated file!  Do not edit.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i know, similar questions have been asked, and i've already looked through everything i
I've looked through numerous similar questions here at SO, but nothing helps. I have
I have looked through lots of similar questions, and I have found out that
I've looked through dozens of pages if similar questions, none of them have any
I have looked through many similar questions and tried the solutions with no success.
OK, I have been looking for weeks now. I have looked through Eclipse and
This is not a duplicate post. I've looked through similar questions on SO but
I've looked through many similar questions, and tried their suggestions, but I'm still getting
I have spent quite some time going through similar questions here and have not
I've looked through the other Stackoverflow questions on this topic and none of 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.