Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.

Query String Parameters

Give Feedback

What are query strings? How do I use them? In this lesson you’ll learn exactly that. The .get() function accepts a params argument, which can be a dictionary, a list of tuples or raw bytes. The following example uses the GitHub Search API looking for the requests library:

>>> requests.get(
...     'https://api.github.com/search/repositories',
...     params={'q': 'requests+language:python'}
... )
<Response [200]>

Comments & Discussion

agerbes on March 14, 2020

Dear Christopher Bailey,

thank you very much for the great tutorial.

I have a special question.

Using the request library I print out the result of the url = ‘www.dropbox.com/h?preview=ophelp.txt

I would like to store the content of this url into it’s name = ‘ophelp’.

How can I use the request library to get the name searching for ‘preview=’ and getting ‘ophelp’?

I thought about using the query string parameters as you shown in your tutorial. But I am not sure how to search for it exactly.

Thank you Anja

Chris Bailey RP Team on March 15, 2020

Hi @agerbes Anja, I’m not sure I completely understand your question. It looks like you want to search for a file on dropbox, and get a preview of the text. I believe searches would be limited to a particular users files. I haven’t used the dropbox api, but I looked it over a bit and you would need to use a different url to use requests with it. The url would be 'https://api.dropbox.com/'. I did find some of the resources available from their site. I hope they can help you with what you are trying to accomplish. This link has the http documentation for using the dropbox api, including the available end points: Dropbox for HTTP

This link is to their Python package for doing development. It looks pretty well documented also: Dropbox for Python Developers. I hope some of this helps.

Become a Member to join the conversation.