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

  • Home
  • SEARCH
  • 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 9187729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:50:45+00:00 2026-06-17T19:50:45+00:00

I am a noob in Python. Just installed it, and spent 2 hours googleing

  • 0

I am a noob in Python. Just installed it, and spent 2 hours googleing how to get to a simple parameter sent in the URL to a Python script

Found this

Very helpful, except I cannot for anything in the world to figure out how to replace

import urlparse
url = 'http://foo.appspot.com/abc?def=ghi'
parsed = urlparse.urlparse(url)
print urlparse.parse_qs(parsed.query)['def']

With what do I replace url = ‘string’ to make it work?
I just want to access http://site.com/test/test.py?param=abc and see abc printed.


Final code after Alex’s answer:

url = os.environ["REQUEST_URI"] 
parsed = urlparse.urlparse(url) 
print urlparse.parse_qs(parsed.query)['param']
  • 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-17T19:50:46+00:00Added an answer on June 17, 2026 at 7:50 pm

    If you don’t have any libraries to do this for you, you can construct your current URL from the HTTP request that gets sent to your script via the browser.

    The headers that interest you are Host and whatever’s after the HTTP method (probably GET, in your case). Here are some more explanations (first link that seemed ok, you’re free to Google some more :).

    This answer shows you how to get the headers in your CGI script:

    If you are running as a CGI, you can’t read the HTTP header directly,
    but the web server put much of that information into environment
    variables for you. You can just pick it out of os.environ[].

    If you’re doing this as an exercise, then it’s fine because you’ll get to understand what’s behind the scenes. If you’re building anything reusable, I recommend you use libraries or a framework so you don’t reinvent the wheel every time you need something.

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

Sidebar

Related Questions

I've just started programming, therefore I'm kinda noob. I'm trying to use python to
Python noob here, Currently I'm working with SQLAlchemy, and I have this: from __init__
I know this is a noob question, but I've worked with Python before and
Python noob; please explain why this loop doesn't exit. for i in range(0,10): print
I am a noob to Python and have not had any luck figuring this
I'm a Python noob and I need some help for a simple problem. What
I keep getting an error whenever I enter this code (I'm a python noob
Python noob so I might be going about this the wrong way I want
I am a noob; trying to create and use a simple webserver in Python
Total Python noob here, probably missing something obvious. I've searched everywhere and haven't found

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.