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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:06:10+00:00 2026-05-30T02:06:10+00:00

import urllib import urllib2 from urllib2 import Request url = ‘https://www.google.com’ response = urllib2.urlopen(url)

  • 0
import urllib
import urllib2
from urllib2 import Request

url = 'https://www.google.com'
response = urllib2.urlopen(url)

login_url = (url + '/login')
data = {'email': 'john',
        'password': 'example'}
req = Request(login_url, urllib.urlencode(data))
response = urllib2.urlopen(req)


  File "test.py", line 50, in <module>
    response = urllib2.urlopen(req)
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 513, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 438, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 521, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
  urllib2.HTTPError: HTTP Error 405: Method Not Allowed

I am doing a POST method. This script works on my MAC OSX running python 2.7.1, however, on my Virtual Machine running python 2.7 it throws that error. Is there some HTTPHeaders I’m suppose to pass along when making a POST request?

  • 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-30T02:06:11+00:00Added an answer on May 30, 2026 at 2:06 am

    you should find the doc that you need here:

    http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html

    For doing the auth you need to use this url https://www.google.com/accounts/ClientLogin which require service that you try to reach and it will provide you an access_token for the service specified

    You need to store cookie for this type of request :

    import urllib2
    import cookielib
    cookiejar = cookielib.LWPCookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
    urllib2.install_opener(opener)
    return urllib2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using urllib (in Python) to fetch an SVG file: import urllib urllib.urlopen('http://alpha.vectors.cloudmade.com/BC9A493B41014CAABB98F0471D759707/-122.2487,37.87588,-122.265823,37.868054?styleid=1&viewport=400x231').read() which
this is the script >> import ClientForm import urllib2 request = urllib2.Request(http://ritaj.birzeit.edu) response =
import os import sys, urllib2, urllib import re import time from threading import Thread
Under Python 3.1, when trying to run this code: from urllib import request def
I have the following fully functional, working code: import urllib.request import zipfile url =
The code below binds an ip address to urllib, urllib2, etc. import socket true_socket
I'm trying to download an image using this code: from urllib import urlretrieve urlretrieve('http://gdimitriou.eu/wp-content/uploads/2008/04/google-image-search.jpg',
I'm trying to use urllib and urllib2 to read from a text file that
I have a Python file with as content: import re import urllib class A(object):
Proxy configuration of a machine can be easily fetched using def check_proxy(): import urllib2

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.