Python Requests Tutorial: Request Web Pages, Download Images, POST Data, Read JSON, and More

In this Python Programming Tutorial, we will be learning how to use the Requests library. The Requests library allows us to send HTTP requests and interact with web pages. We will be learning how to grab the source code of a site, download images, POST form data to routes, read JSON responses, perform authentication, and more. Let’s get started…

BeautifulSoup Tutorial –

File Objects Tutorial –

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –

#Python #Requests


Xem thêm bài viết khác:


  1. My next video will be a real-world example of a script I wrote to monitor my personal website. We'll use the Request library to monitor the site, and if it is down then we will learn how to send an email and automatically restart the server. I hope everyone finds this useful! Hope you're having a great week!

  2. 10:04 Yeah, I think that same thing every time I open any library. Respect to those guys

  3. r.json() it’s not working for me 😤😤😡

  4. Hi Corey! thanks for this video.
    Can you please upload video about how to parse html page after login and save the cookies?
    I tried to take some value from http page each day and it gives me error since the cookies change (using on curl)

  5. People are excellent, and so are you(^///^)

  6. Genial Corey, me gusto el video y era lo que buscaba, una explicación rápida y clara de que es requests y ademas lo haces con profesionalidad (+sub)

  7. @Corey Schafer Amazing video , although I have a question which is kind of specific. I am trying to parse my companies website to create a database but am not able to do that. I found a library called requests_ntlm but coudn't make the code work. Any guidance will be really helpful

  8. hi Corey, I have a question: How do i determine the download speed using requests library through a script? I don't wanna use pyspeedtest.

  9. 10:06 dude, welcome to the club. Your videos alone make most of us feel the same way so I can only imagine if these people from your perspective are another step up in productive… then I'm completely puzzled! Anyway, thanks for a great video Corey!

  10. How could you import text files from sharepoint to python and save it as an excel file in a folder

  11. "Module 'requests' has no 'get' member"

  12. Hi Corey, can you do a video on http redirects and how to capture the tokens that are generated in the url… your response is much appreciated

  13. Corey, you're the best 🙂

  14. is this good if I want to learn RESTFUL API?

  15. @Corey Schafer When I try to run 'requests', ST3 gives me a ModuleNotFoundError that 'requests' does not exist. I have already tried to follow the dependencies documentation on but can't seem to make this work. Any advice on how to set this up?

  16. For anyone who needs the most of the code written in this session :

    #pip install requests

    import requests





    #downloading images


    #writing a downloaded image to system

    with open ('comic.png', 'wb') as f:


    #200 is success
    #300 is redirects
    #400 are client errors .ie. if you don't have access or permission for you
    #500 are server errors

    #Return true for anything less than 400

    payload= {'page':2,'count':25}
    r=requests.get('', params=payload)

    payload= {'username':'corey','password':'testing'}'', data=payload)
    #data is used for payload to be more likely in a form

    #no args as it is a url parameter
    #form is uploaded
    #to know what values the 'form' url expects, we need to look at the source code
    #of the url

    #most of the times the output we get will be in json, so we have method we could use

    #created a python dictionary from json response

    #to capture that in a variable

    #the authentication done above is form based authentication
    #there are other types of authentication like basic authentication
    #'' this a url which basic authentication
    #and accepts only username= corey and password=testing

    #in auth, we provide a tuple for input parameters

    r=requests.get('', auth=("corey","testing"))

    r=requests.get('', auth=("coreyms","testing"))
    #<Response [401]> , so unauthorized response

    #when checking if website is working or not it is good practice to keep "timeout"
    #or else it might hand indefinitely, exceptions if api's in website take too much time to load

    #'{delay} is used to delay the site by certain time
    r=requests.get('', timeout=3); print(r)

    r=requests.get('', timeout=3) ; print(r)

  17. If someone is struggling installing requests, try to use pip3. The 'pip install requests' did not work for me. I had to use 'pip3 install requests'.

  18. Thanks! It was very informative but I have one question. What do we use the stream=True keyword argument for? I looked at the documentation but I didnt really understand that.

  19. Thanks for the great tutorials

  20. When I try to download the image it doesn't save anything on the folder.

  21. Thanks. Save me a lot of time and effort.

  22. Perfect as always !

  23. Excellent delivery Corey… the best!!

  24. Stupid idiot showing example how to download image from page where is llink of image showed. Also subtitles not working. Piece of shit.

  25. Hey Corey, I was looking for python SAML SSO based authentication but it seems there isn't much on internet

  26. You have got passion in your voice which is helping people like me to learn programming in a much fun way. Love you for what you are. love you 3000.

  27. Sir, How to Solve UnExceptedAlert Exception Of Selenium Module Python.
    I'm Writing Code To Download Pdf Of Same Name And And on Some Name An Unexpected Alert appears ….
    Plz Suggest A Way To Remove The Exception

  28. Outstanding tutorial! Thanks for the coaching and for pointing out the httpbin tool!!!

  29. Hello, i am getting an error when i tried to use requests.get(url) as failed to establish a new connection :[errno 11001] getaddrinfo failed. What should i do to resolve this @corey schafer

  30. Hello, can anyone please help me get tracking info from this page using a get or post method? Much appreciated

Leave a Reply

Your email address will not be published. Required fields are marked *