Pravi
Pravi

Reputation: 108

How can I get variables from URL using Python(2.7)?

The following works when I paste it on the browser:

localhost://api/get_url.py?x=xxx&y=yyy

how can i store the values of x and y in a variable passing from url ?

Upvotes: 2

Views: 117

Answers (1)

blhsing
blhsing

Reputation: 106936

The requests module has made it really simple.

Please read: http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls

import requests
response = requests.get('localhost://api/get_url.py', params={'x': x, 'y': y})

Upvotes: 1

Related Questions