Website login using requests library in Python

Поділитися
Вставка
  • Опубліковано 30 лип 2024
  • IN this video, learn the step by step procedure to login to a website using requests library in Python.
    Example code here: gist.github.com/nikhilkumarsi...
    Intro to web scraping:
    indianpythonista.wordpress.co...
    Intro to requests library:
    indianpythonista.wordpress.co...
    ------------------------------------------------------------
    Explore my tutorials: nikhilkumarsingh.github.io/tu...
    More awesome topics covered here:
    WhatsApp Bot using Twilio and Python : tinyurl.com/y9n9ott5
    Serverless Rest API using AWS and Python : tinyurl.com/y8yg4vem
    Creating Chat Application using Flask, Socket.IO & mongoDB : tinyurl.com/y8kbn4xu
    Curses in Python : tinyurl.com/y8ws3x4l
    Discovering Hidden APIs : tinyurl.com/y7sdegoq
    RegEx in Python : tinyurl.com/y84cnuns
    Python for Data Science : tinyurl.com/yd7x6j5e
    Introduction to Pandas : tinyurl.com/ycr4qytt
    Introduction to Matplotlib : tinyurl.com/y8caem3r
    Introduction to Numpy : tinyurl.com/yc8uhtn9
    Functional Programming in Python : tinyurl.com/ybubzum6
    Python Package Publishing : tinyurl.com/ya2fn3wb
    Multithreading in Python : tinyurl.com/ycnummb8
    Multiprocessing in Python : tinyurl.com/y8qkjqtx
    Parallel Programming in Python : tinyurl.com/yakl5udt
    Concurrent Programming in Python : tinyurl.com/y9ppkkhc
    Dataclasses in Python : tinyurl.com/y8zfqleq
    Exploring UA-cam Data API : tinyurl.com/y7jhs8rm
    Just For Fun : tinyurl.com/y9on8gb5
    Exploring AWS : tinyurl.com/ydxmhhz9
    Jupyter Notebook (Tips, Tricks and Hacks) : tinyurl.com/y8qdhcrp
    Decorators in Python : tinyurl.com/y7ghraa9
    Inside Python : tinyurl.com/yd8xqbjj
    Exploring datetime : tinyurl.com/y96jzylm
    Collections in Python : tinyurl.com/ybxltgvk
    Networking : tinyurl.com/y97eroql
    Computer Vision for noobs : tinyurl.com/y8pxz436
    Python for web : tinyurl.com/y829py3g
    Awesome Linux Terminal : tinyurl.com/y8no3zso
    Intermediate Python : tinyurl.com/yasmecaw
    Tips, tricks, hacks and APIs : tinyurl.com/y9xqzzl4
    Optical Character Recognition : tinyurl.com/ybt3to6q
    Facebook Messenger Bot Tutorial : tinyurl.com/y9wvjc9g
    Facebook: / indianpythonista
    Github: www.github.com/nikhilkumarsingh
    Twitter: / nikhilksingh97
    ------------------------------------------------------------
    #python #requests #logging

КОМЕНТАРІ • 293

  • @eerik6571
    @eerik6571 3 роки тому +49

    By this time my code consists of: 25% Stack overflow scripts, 10% my own work, 40% people sharing ideas on UA-cam and 25% pure luck (no one know how or why the code works but it does!). Thank you so much for this video!

  • @HardeepSingh-sm5pc
    @HardeepSingh-sm5pc 4 роки тому +14

    Dude, This is like the most underrated Python Programming channel I have ever seen.
    subscribers = 0
    while True:
    subscribers+=100
    print("Nice Content"*99999)

    • @clurdy649
      @clurdy649 3 роки тому

      LOL

    • @simthegreat5690
      @simthegreat5690 2 роки тому +1

      it will never print "Nice Content"*99999 since you have an infinite loop

    • @4kumetsu
      @4kumetsu 2 роки тому

      @@simthegreat5690 loool

  • @noahbroyles8828
    @noahbroyles8828 4 роки тому +7

    Very nice!
    Just keep in mind that different sites use different tokens to login with. You may need to play around in the inspector for a bit until you find it.

  • @coucal
    @coucal 4 роки тому +2

    Super cool, I was struggling to login into an ASP login, with your neat steps and some tricks I am able to get in now :)

  • @SirPottsalot
    @SirPottsalot 4 роки тому

    After hours of searching for a way to edit online forms through a python script. (I'm a noob at requests) This video gave me all the tools I needed in ~12 mins. Wish I had found this earlier...

  • @vuinx
    @vuinx 4 роки тому +1

    very clear instructions and explanation. great job and thanks for the tutorial

  • @manfredsaxshar8939
    @manfredsaxshar8939 5 років тому +2

    Really great video. Thank you pretty much.

  • @PatrykKodym
    @PatrykKodym 5 років тому +6

    Thank you! Useful stuff :)

  • @cristif92
    @cristif92 4 роки тому +2

    Thank you ! Now I get it with the options like headers and login_data ... and also where I get the login_data dictionary values ! Thanks man ! :)

  • @iamakifislam
    @iamakifislam 4 роки тому

    Before start watching, I want to say thank you !

  • @arminhejazian5306
    @arminhejazian5306 4 роки тому

    Finally found what i was looking for ...thank you for high quality content

  • @swagatjena6888
    @swagatjena6888 4 роки тому +2

    Thank you. This helped a lot!

  • @hkbtdragdragfly542
    @hkbtdragdragfly542 5 років тому

    Awesome video! Keep up the great work guy!

  • @akashmaurya1996
    @akashmaurya1996 2 роки тому

    BestT 12 mins of Educational video ever!!!

  • @pczaomyworld777
    @pczaomyworld777 4 роки тому

    I followed the instructions and it really worked

  • @markscheck
    @markscheck 4 роки тому

    Great video, I learned alot! Keep up the good work!

  • @rogerwprice
    @rogerwprice 5 років тому

    Super useful and well explained - thanks!

  • @ViridianMarmot
    @ViridianMarmot 5 років тому

    Great tutorial, thanks a mil man!

  • @arnau02
    @arnau02 3 роки тому

    Thank you very much indeed, this video has helped me doing exactlly what I wanted, and with 0 errors. Now that I understand it thanks to you, I can keep doing my work. You're great :D

  • @alexpujolcomet976
    @alexpujolcomet976 4 роки тому +7

    You're the best!!!

  • @CasperWest
    @CasperWest Рік тому

    If I wanted to make a post request, do I need to main website or the request url link in the dev tools?

  • @hyllervianna
    @hyllervianna 4 роки тому +1

    THANK YOU !! U saved my life!

  • @MillPillGames
    @MillPillGames Рік тому

    hey and is there anyway to parse javascript values ? cuz there is a needed header that i need to send on the post method , how can i get this header value ( knowing that its calculated in a js FILE ) from what i have seen in inspector

  • @moegreen4395
    @moegreen4395 5 років тому

    Thanks for the video ! :)
    I have an additional question. I wish to get the redirected url, that is in Web Inspector under the name "location". Yet I cannot see it anywhere in the soup. From where can I get it ?

  • @darklionking3341
    @darklionking3341 5 років тому

    Thanks for this tutorial, good work.

  • @Waldo8226
    @Waldo8226 4 роки тому

    Thanks for tutorial, helped my project!

  • @VicoSurge
    @VicoSurge 2 роки тому

    Exactly what I needed, thanks for the video!

  • @RNBnewsIndia
    @RNBnewsIndia 4 роки тому

    Bro I have m3u8 which is encrypted
    I have key
    But I don't know how to decrypt the file ?

  • @zzbaz2000
    @zzbaz2000 4 роки тому

    Awesome, thank you so much!

  •  5 років тому

    amazing video, it looks very simple, thanks man

  • @mariodouglasa.cabral8842
    @mariodouglasa.cabral8842 4 роки тому

    You're the best!!!
    Thank you very much

  • @igorbarros9620
    @igorbarros9620 4 роки тому

    Great content, sir. Thank you!

  • @dayofagbenro8476
    @dayofagbenro8476 4 роки тому

    THANK YOU FOR THIS VIDEO!

  • @dizz9719
    @dizz9719 4 роки тому

    Thank you! It really helped me with my poject

  • @elivakrat5654
    @elivakrat5654 5 років тому

    Thank you! Great Video!

  • @anota
    @anota Рік тому

    Thank you so much! This helped me a lot, with this explanation I was able to submit in multi page forms. Greetings from Brasil! ⭐⭐

  • @InteligenciadeNegocios
    @InteligenciadeNegocios 4 роки тому +1

    i cannot find the form_build... how can we solve that? or what can we do? help please!

  • @ujjwalrustagi8690
    @ujjwalrustagi8690 3 роки тому

    The video that I was looking for. Thanks.😊

  • @PrasanthChandraLingala
    @PrasanthChandraLingala 4 роки тому

    Thank you for nice explanation.

  • @adityakulkarni3396
    @adityakulkarni3396 4 роки тому

    Hey, i have a python script that fetches attendance for which i use selenium for logging in and everything works pretty fine, but my question is that after ruuning the script it automatically opens up the browser and does the login and then clicks on the specified link to fetch the attendence !...............What to do if i want to do all of this behind the scene without the browser actually been showing up?

  • @nilacof
    @nilacof 5 років тому

    good video and explanation! thanks!

  • @michelezanotti9083
    @michelezanotti9083 4 роки тому

    And what if in my html there are more then one form_key (because there are more actions (login, register, newsletter)? The key are in the same

  • @conor4289
    @conor4289 4 роки тому

    Very helpful. Thank you!

  • @DAWE12100
    @DAWE12100 4 роки тому +1

    OMG! Thank you soooo much!!!!

  • @mimidhr
    @mimidhr 5 років тому

    Great, thanks a lot from Morocco

  • @MiRaje8086
    @MiRaje8086 5 років тому

    Hey man I tried this but the website I'm trying has 2 POST requests. One to login, and one to validate with a unique token. The problem is when I try to parse the URL it's using to 'validate' it says error parsing body. So I can get the unique token value. Any tips?

  • @MrTaken-tl4bw
    @MrTaken-tl4bw 2 роки тому

    great video, very helpful to scrape website protected with login

  • @she.....
    @she..... 5 років тому +1

    Great video. I was trying to do something similar in java without using selenium. This helps.

    • @swadhikarc7858
      @swadhikarc7858 5 років тому

      Still using Java at this modern age for web scraping?

  • @sandipbamrel2087
    @sandipbamrel2087 5 років тому

    wow bro i learned good thing today

  • @bilalghelima3666
    @bilalghelima3666 3 роки тому +2

    When I run the code, it just prints out thelogin page, why is this happpening

  • @monicavigoni3253
    @monicavigoni3253 4 роки тому

    hi, the website i am trying to login does not show the csrf. only when i inspect i can see it. but then it is omitted.
    any idea how to get it?

  • @dhyanpatelbitspilanitotamu1520

    Thank You Nikhil for the video.
    I am facing an issue while using this code to login into a microsoft page, specifically Sharepoint page which is a kind of company's internal site.
    Also, when I inspect on the sharepoint homepage to look for user-agent and form_build_id, I can find the user-agent, but cannot find the form_build_id information. There is no section of "Form Data" under the Network when I inspect. Is it because the sharepoint login is "Connected to Windows"? Can you please help me out here?

  • @Reedmax
    @Reedmax 4 роки тому

    I just ask if i send request and the web site have 504 bad getaway time out , the request success or not please

  • @ryanthurston1305
    @ryanthurston1305 4 роки тому +1

    Dude, thank you!

  • @kursdragon
    @kursdragon 4 роки тому

    Hi I'm trying to do this and I'm looking at a website that I'm trying to login, but when I submit my login information and click the "login" button I don't get a "post" notification, just a "get" request which is called app.js, anyone know what to do in this situation?

  • @ilkersagkaya4568
    @ilkersagkaya4568 3 роки тому

    I can not find form build id in my login form data headers or anything seems like it with a different header name. What can I do about it?

  • @lucaslau8379
    @lucaslau8379 5 років тому

    I don't see anything about login data from indexPage.action, only encrypted cookies, what should I do?

  • @_xylotus_
    @_xylotus_ 4 роки тому

    I want to login into facebook as a sample. And when I click the "login" button I always find the "www.facebook.com" network process but Its an "get" request with the code "200". I cant seem to find a post request with the categorie "Form Data" with password and username in it (etc.)

  • @rs-tarxvfz
    @rs-tarxvfz 4 роки тому

    Hey dude, do you have something for SAML v2 based Single Sign On?

  • @harinath_mishra
    @harinath_mishra 3 роки тому +1

    There is csfr token also now a day how to get that for login_data pls tell

  • @lowerpass2000
    @lowerpass2000 4 роки тому

    Dude you're awesome! Ty

  • @michelleliew7341
    @michelleliew7341 4 роки тому +4

    For those who cannot login access to the url, there's a new item under 'Form Data', which is 'csrfToken'. You'll need to include it to the 'login_data' using the same method searching for 'form_build_id'.
    Code for 'csrfToken':
    login_data['csrfToken'] = soup.find('input', attrs={'name': 'csrfToken'})['value']

    • @ashwinis.chavan4598
      @ashwinis.chavan4598 4 роки тому

      Hello Michelle, were you able to login to the same site after card token addition? I am getting 200 response but the username and password fields are empty

    • @michelleliew7341
      @michelleliew7341 4 роки тому

      @@ashwinis.chavan4598 Hi, I suppose you need to have an account of the website beforehand. Then, you shall use your password and username in the code.

  • @yusuferarslan3851
    @yusuferarslan3851 4 роки тому

    The website that i want to try to scrap, don't have form data area. So i can't get formbuild id name etc. Can u help about it ?

  • @Daffo
    @Daffo 4 роки тому

    can someone help me trying to do this for slamjamsocialism but can't find the login request?

  • @suhaasvellanki8504
    @suhaasvellanki8504 4 роки тому

    um can someone help me out here?
    I copied the video word for word but the error 'TypeError: 'NoneType' object is not callable' is showing up
    for this line:
    login_data['form_build_id']=soup.find('input',attrs={'name':'form_build_id'})['value']
    I have no fricken idea as to why this is happening.

  • @qwertyx141
    @qwertyx141 5 років тому +1

    thank you very much

  • @Brainneeds
    @Brainneeds 5 років тому

    you earned a sub , thank bhai

  • @cshekar100
    @cshekar100 4 роки тому

    Thank you so much it is very helpful ...nikhil

  • @pedropancho3128
    @pedropancho3128 5 років тому

    Very useful. Thanks

  • @vielmond1840
    @vielmond1840 2 роки тому

    Very good. Thanks!

  • @tuskiie
    @tuskiie 4 роки тому +16

    what should i do if there is nothing called 'form_build_id' and there is no value?

    • @fordlab22
      @fordlab22 4 роки тому

      skip and watch another video

    • @shekh4r
      @shekh4r 4 роки тому +1

      Check post request

    • @EdwinEnriquezMX
      @EdwinEnriquezMX 4 роки тому

      @K H check if your site have something like a token, in the request headerss.

  • @hemantgore2567
    @hemantgore2567 4 роки тому

    I tried this and got SSL exception
    requests.exceptions.SSLError: HTTPSConnectionPool(host='mwhlvcmut2.corp.amdocs.com', port=28501): Max retries exceeded with url: /B2B (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)')))
    can you please help me here?

  • @34_shivamsingh68
    @34_shivamsingh68 5 років тому

    Pure Gold !!!

  • @bkshows9141
    @bkshows9141 4 роки тому

    Very helpful video thanks

  • @OverloadedSlime
    @OverloadedSlime 4 роки тому

    Awesome man!!!

  • @arunmpkumar
    @arunmpkumar 4 роки тому

    Very useful video; thank you (y)

  • @Pablo-wy1ui
    @Pablo-wy1ui 3 роки тому

    Thank you so much!!!

  • @pratyakshyt
    @pratyakshyt 4 роки тому

    hi sir im not able to log in to my website.. actually it is a website for our college academics, which is acccesebile through a vpn, the get request is working fine but post request fails ..
    please help asap

  • @rbk00006
    @rbk00006 4 роки тому

    hey dude,im getting the 405 Not Allowed error even after passing the headers..plz help

  • @jake2663
    @jake2663 Рік тому

    Very helpful thank you

  • @evil_beast_z
    @evil_beast_z 2 роки тому

    Can u help me..
    How to inspect a website network requests in android?
    To get form data

  • @mrjack7975
    @mrjack7975 4 роки тому

    Can you help me with this ?
    login_data['csrfToken'] = soup.find('input', attrs={'name' : 'csrfToken'})['value']
    TypeError: 'NoneType' object has no attribute '__getitem__

  • @TheHitessh
    @TheHitessh 4 роки тому

    We have something called requests.auth, in which we have a class named HTTPBasicAuth which serves the same purpose. Is it possible for you to explain that?

  • @cuongnguyenthe6593
    @cuongnguyenthe6593 5 років тому

    bro can you help me. my response is 405 error: Method is not allowed.

  • @Errorcode-hq5wg
    @Errorcode-hq5wg 4 роки тому

    Thank you so much

  • @bakanayi
    @bakanayi 3 роки тому +5

    Hey cool tutorial. One question, the website i am trying to do this on has an encrypted password in the form data. How can we go about doing it?

    • @pronoyghosh2803
      @pronoyghosh2803 3 роки тому

      did u try passing the encrypted password as the value for password key?

  • @devarshsanghvi9315
    @devarshsanghvi9315 2 роки тому

    Thanks for the efforts

  • @hperezcu
    @hperezcu 4 роки тому

    your example work , I tried with another website in our intranet and I am unable to login,. I just replace the url (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

  • @angelvargas9681
    @angelvargas9681 4 роки тому

    How can I do if the developer tool does not show me form data? Please help me with this, thanks in advance

  • @barkhasharma8294
    @barkhasharma8294 4 роки тому

    why it is post request?? I have tried one website and login there it was showing me get request with status code 200???????????

  • @fantasticprajwal7442
    @fantasticprajwal7442 3 роки тому

    How we can scrap the website where SAML authentication is there

  • @thestonedgamerz8533
    @thestonedgamerz8533 4 роки тому

    I have used the same thing exactly but my problem is different.
    After Authentication, there is a long loading page then using content.text i get tags of that loading page html instead of one after the loading is done

  • @alfiyansubair7617
    @alfiyansubair7617 3 роки тому

    i want to login to a website using requests but the login form is an can you explain me how?

  • @paulblack2649
    @paulblack2649 5 років тому

    Great tutorial

  • @utkarshkulshrestha6783
    @utkarshkulshrestha6783 5 років тому +2

    Help please. In your line number 19 in git code its showing "TypeError: 'NoneType' object is not subscriptable."

  • @ngocthangphan8968
    @ngocthangphan8968 Рік тому

    so if you don't enter the header is it ok?

  • @Xantium0
    @Xantium0 4 роки тому +2

    Great video. Very helpful for getting started. However what do I do if I get redirected from my login page. For example say I log in at www.example.com, and press sign in, and I get redirected to www.example.com/account
    How do I scrape the page from there

  • @oussamamoussaoui5821
    @oussamamoussaoui5821 3 роки тому

    Thank you so much bro

  • @UnitySimplified
    @UnitySimplified 2 роки тому

    Thanks you so much sir

  • @jackroark6928
    @jackroark6928 4 роки тому

    Love it!