1

I'm trying to construct a URL based on what I get from a initial URL.

Example:

URL1:

http://some-url/rest/ids?configuration_path=project/Main/10-deploy

Response here is 123

URL2:

http://abc-bld/download/{RESPONSE_FROM_URL1_HERE}.latest_successful/artifacts/build-info.props

so my final URL will be:

http://tke-bld/download/123.latest_successful/artifacts/build-info.props

Response here is Some.Text.here.123

Then I'd like to grab 'Some.Text.here.123' and store it in a variable.

How can I accomplish this with python?

Any help would be much appreciated. Thanks

2 Answers 2

1

Assuming that you are doing simple HTTP GET requests, you can use the requests library

Something like

import requests
initial_request = requests.get('http://request1.com/something')
value = request1.text

second_request = requests.get('http://request2.com/value={0}'.format(value))
response = second_request.text
Sign up to request clarification or add additional context in comments.

Comments

1

You can do it via requests and some string formatting, something along these lines:

import requests

initial_url = "http://some-url/rest/ids"
initial_url_params = {
    "configuration_path": "project/Main/10-deploy"
}
with requests.Session() as session:
     response = session.get(initial_url, params=initial_url_params)

     second_url = "http://abc-bld/download/{0}.latest_successful/artifacts/build-info.props".format(response.content)

     response = session.get(second_url)
     print(response.content)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.