How I use SELENIUM to AUTOMATE the Web with PYTHON. Pt1

  Рет қаралды 72,651

John Watson Rooney

John Watson Rooney

Күн бұрын

Пікірлер: 97
@cloudybrains
@cloudybrains 4 жыл бұрын
I spent hours trying to find nested divs in a website I needed to scrape today and I didn't know you could just copy the xpath from the inspector. This video is a godsend lol.
@ChiefRemoteOfficer
@ChiefRemoteOfficer 3 жыл бұрын
XPath will work but consider it a last resort. It is fragile and will likely break if the order of tags on the page changes.
@ChiefRemoteOfficer
@ChiefRemoteOfficer 2 жыл бұрын
@@LifePointeChurch1616 A unique ID is best if you have one on the page.
@BILLYSPROCKET88
@BILLYSPROCKET88 4 жыл бұрын
I had a webscraper project for the covid quarantine and this is the first tutorial out of 5 that was helpful! Thanks a bunch!
@JohnWatsonRooney
@JohnWatsonRooney 4 жыл бұрын
Glad you found it useful!
@TheKrannyMaster
@TheKrannyMaster 2 жыл бұрын
Hey John, Whenever I have to do anything with web scraping or interacting with web browsers I always watch your videos. Keep up the good work!
@pratikgazelli
@pratikgazelli 2 жыл бұрын
Note: AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath' Reason:- driver.find_element_by_xpath() has been removed from selenium. Instead we can now use : - driver.find_element("xpath", '//*[@id="username"]') Hope it helps.
@azhari7968
@azhari7968 2 жыл бұрын
thanks!
@datadecides
@datadecides Жыл бұрын
Thanks Buddy
@dhimassetyapamungkas9160
@dhimassetyapamungkas9160 Жыл бұрын
how about send_key icant find them too ?
@hananemeftahi202
@hananemeftahi202 2 жыл бұрын
Great video. We need another video on how to avoid bot detection with selenium
@coolbones2747
@coolbones2747 4 ай бұрын
Hello sorry if this a dumb question but what do i do if the script opens the webpage but keeps closing it right aftrer all together with the browser?
@martpagente7587
@martpagente7587 4 жыл бұрын
Sir can you make more videos about web scraping using selenium. I like the way you teach, I love your channel from Philippines. Simple, Clear and Short.
@BodhiSoftMobileApps
@BodhiSoftMobileApps 8 ай бұрын
00:57 - why install it for a separate user account only? Sorry for the n00b question but I'm guessing this is a security concern? Are you wanting to ensure that admin accounts cannot run it?
@robgallo_peak
@robgallo_peak 3 жыл бұрын
Great videos John.
@javierpasetti2947
@javierpasetti2947 3 жыл бұрын
Great video. I am going to use it to get bond prices. There are so many relationships to monitor that the only possible way to do it is using a Python program. Thanks so much.
@oneminute4565
@oneminute4565 3 жыл бұрын
how we automate in case of when we see capture functionality before login, please guide
@higiniofuentes2551
@higiniofuentes2551 2 жыл бұрын
When getting the url and the Chrome browse appears, how to solve the question asking for connection to an account? Thank you!
@mattmovesmountains1443
@mattmovesmountains1443 3 жыл бұрын
Not sure if you ever use Selenium on a Linux machine (RPi in my case), but I've found... it's needlessly difficult to get started. After a bunch of research, I found what might not be the best answer, best practices, etc... but it seems to work. First you [sudo apt-get chromium-chromedriver] instead of a regular chromedriver, since finding a suitable chromedriver for Chromium seems to be a tedious process from questionable sources. Then, a stack overflow response mentioned reconfiguring your webdriver options to set your Chrome path to actually point at your Chromium browser. I like it because it's hacky, and so am I. Perhaps worth noting: it was a low-ranking stack overflow response, but it was relatively understandable to a layperson such as myself. I wondered if you knew a better way, or knew any reasons that I should not use this method. Or possibly this is helpful information to you? In any case, wanted to pass it along.
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
I did once wrestle with it to get it to work well on a linux server, involving creating fake displays and everything. I copioed so many commands that I had no idea what they really were.. But it did work. I don't use Selenium much now but if I have to I go headless and use Helium (this works on WSL2). Only downside it won't load up not in headless mode so no browser popping up to see whats going on. check it out if you havent done already: github.com/mherrmann/selenium-python-helium
@mattmovesmountains1443
@mattmovesmountains1443 3 жыл бұрын
@@JohnWatsonRooney I've started using Helium since you did the tutorial a while back. Kind of a magic module, though I haven't been able to make executables out of py files that run helium, so I'll sometimes go back to selenium if needed. In terms of running selenium on Linux, in my case I'm just using the pi as a day-to-day machine so I don't have to worry about virtual displays, but I did run into that chromedriver issue from my comment above, so I figured I'd mention it. I'm taking a Data Science course, and someone was setting up a scraper with Selenium, which led me down this rabbit hole.
@hubabokuti
@hubabokuti Жыл бұрын
So how 's that the browser doesn't get closed after just popping up. I need a few more commands for that.
@AliKhan-gg2lh
@AliKhan-gg2lh Жыл бұрын
Brother i used the same code but it doesn't put the credentials there. There is no error as well. Any solutions?
@briansu7877
@briansu7877 3 жыл бұрын
I really enjoy learning skills from your tutorial. May I share your video and take notes on my medium article? I will label where it is come from.
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
Of course, please do!
@flexicution2323
@flexicution2323 3 жыл бұрын
Hey the //*[@id etc is underlined and says expected expression
@35ysf35
@35ysf35 2 жыл бұрын
thanks for videos mr John
@JohnWatsonRooney
@JohnWatsonRooney 2 жыл бұрын
My pleasure!
@sayantansarkar6433
@sayantansarkar6433 4 жыл бұрын
Nice simple and helpful one.. thanks for keeping the video so easy to learn..🤗
@wrathofainz
@wrathofainz 2 жыл бұрын
I wonder if I can use this to scrape videos from a site that locks when you open the developer tools? Like, on the site if you open them it will hit a breakpoint and then navigate away.
@SaeedAhmed028
@SaeedAhmed028 2 жыл бұрын
just subscribed and wondering where I can find the new stuff or updated one thanks
@med12med
@med12med 8 ай бұрын
Simple and useful. Thanks.
@sanjanaprakashbabu
@sanjanaprakashbabu 5 ай бұрын
in which ide is this done? can we do in Vscode?
@keistzenon9593
@keistzenon9593 3 жыл бұрын
didn't know it could be so easy! Now I have to give this a try :)
@rAskRedditHighlights
@rAskRedditHighlights 2 жыл бұрын
Does anyone know if there is a way to use selenium but on an already existing tab (so i don't have to sign in on the thing it opens)
@SagarJaspal
@SagarJaspal 3 жыл бұрын
Came here for something like implicitly_wait, wasn't disappointed! Thanks for the video.
@rajeevmenon5945
@rajeevmenon5945 2 жыл бұрын
how will you ask for an input to accommodate OTPs while logging into a URL ? The OTP is different every time to be hard-coded :-(
@catsandmusic4635
@catsandmusic4635 3 жыл бұрын
This tutorial saved me in ways you cannot comprehend.
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
Thanks I’m glad I could help!
@user-hu9ch3bi4f
@user-hu9ch3bi4f 2 жыл бұрын
Hello, I have a question for you. Now I have some problems. of the request for a login web page, but the server responded with another page. I believe the server may be experiencing too many concurrent access statuses. Question: How can we solve this problem? I would like to ask for ideas sir.
@rverm1000
@rverm1000 3 жыл бұрын
havent used selenium yet. can it be used to interact with programs at work to make the job easier by automating some task?
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
It can control a web browser so as long as your work programs are online then yes it absolutely can
@rverm1000
@rverm1000 3 жыл бұрын
@@JohnWatsonRooney no there local to the business. maybe i can ask permission from the company software developers
@startcode6096
@startcode6096 2 жыл бұрын
This stuff is really gold !! Thanks for this video
@mikkiverma9545
@mikkiverma9545 3 жыл бұрын
Thanks John it really helped me
@AD-gi2sw
@AD-gi2sw 4 жыл бұрын
Great content, love you vids can't wait for more. I am starting python and some of your videos have helped me keep up the good work
@JohnWatsonRooney
@JohnWatsonRooney 4 жыл бұрын
Glad I could help! More videos to come!
@Zack-ni3vz
@Zack-ni3vz 2 жыл бұрын
do you know, how to automate multiple choice questions using selenium python? where the questions change every time the course is opened
@atsource3143
@atsource3143 2 жыл бұрын
Hi John, just wanted to know is there any way to scrap hidden div tags/elements using playwright, beautifulsoup etc? Thanks
@pratikgazelli
@pratikgazelli 2 жыл бұрын
I was able to run the entire code except the last print function. can someone help?
@mostafa5863
@mostafa5863 2 жыл бұрын
Thanks for your useful video
@shankarpoudel6260
@shankarpoudel6260 3 жыл бұрын
Thanks man. Very useful. Hopeful to get a scrapping gig.
@dzeykop
@dzeykop 3 жыл бұрын
Thank you John, great work, again
@BhaktiVani1
@BhaktiVani1 3 жыл бұрын
big fan bro
@xiaoming4136
@xiaoming4136 3 жыл бұрын
Can I crawl video from the web? Is there any tutorial video?
@JNET_Reloaded
@JNET_Reloaded 6 ай бұрын
cant install from command line and u didnt put a link to site
@stewielol
@stewielol 4 жыл бұрын
After executing the first line of code, Chrome closes immediately. Any idea on how to keep it open?
@GorkaSA-d8f
@GorkaSA-d8f 11 ай бұрын
I know I am too late as I have just came across with this video. You can add the followwing code before opening the URL. This code helps you to configure the chrome options for the webdriver: options = webdriver.ChromeOptions() options.add_experimental_option("detach", True) driver = webdriver.Chrome(options=options)
@JNET_Reloaded
@JNET_Reloaded 6 ай бұрын
erv2 $ sudo apt install -y chromium-chromedriver Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package chromium-chromedriver how do i get this on my rpi 5 arm raspian 64bit?
@rrahll
@rrahll 4 жыл бұрын
Mb you can continue Selenium series with some other videos?))
@JohnWatsonRooney
@JohnWatsonRooney 4 жыл бұрын
Sure I’ll look into doing more
@rrahll
@rrahll 4 жыл бұрын
@@JohnWatsonRooney thank you!
@wangdanny178
@wangdanny178 2 жыл бұрын
My handsome John, before I watched this, I was trying install chrome webdriver using books. It took me 2 hours on google to find the default path. What should I say? I should have watched your video sooner.
@MuhammadAbdullah-lr7sd
@MuhammadAbdullah-lr7sd 2 жыл бұрын
Thank you soo much for this helpful content.
@paulohsgoes1959
@paulohsgoes1959 4 жыл бұрын
Good job. You've just got a new subscriber!
@saadachab8425
@saadachab8425 3 жыл бұрын
Ver y good explained, thank you
@jamessingleton4856
@jamessingleton4856 3 жыл бұрын
Brilliant! Thanks so much
@razaluminite
@razaluminite Жыл бұрын
Keep it up! :)
@JohnWatsonRooney
@JohnWatsonRooney Жыл бұрын
thanks!
@paveldanilov4869
@paveldanilov4869 2 жыл бұрын
thanks for the video!!
@111ark
@111ark 4 жыл бұрын
Super useful
@shreevaishnavibaddala4668
@shreevaishnavibaddala4668 2 ай бұрын
this is for linux, then how we have to do for windows
@johnyev9315
@johnyev9315 3 жыл бұрын
Thank you so much sir
@jonathanhammond5563
@jonathanhammond5563 3 жыл бұрын
So far, I was able to use this tutorial to get through part way of a job interview coding challenge. The challenge: - using selenium, - log into a website, - where occasionally visiting the website results in an error, - and grab the contents of a table, - which only appears after a loading element, - which also occasionally results in an error, - and output the data into a CSV. So far, I have been able to log into the website just by using this Pt.1. However, I only now am noticing that there are errors that they have planted in the challenge, and I am unable to use xpath for the table since they have made duplicate ids (same id value) for multiple elements just to screw with me. On top of that, I am currently logging the loading data even though I have the implicitly_wait(20), so am going to have to look into that. Hopefully Pt. 2 gets me closer to getting hired! Cheers
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
Glad its helped you! depending on the site you might find that after logging in, you can call the driver.source and parse the data with BS4 - this could be quicker and easiser.
@jonathanhammond5563
@jonathanhammond5563 3 жыл бұрын
@@JohnWatsonRooney thanks a lot! I was able to get the job done with Selenium and pandas. I had to punt on fault-tolerance sadly. Do you think you’ll ever make content regarding error handling with web scraping?
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
@@jonathanhammond5563 Oh thats great. Yes I am planning on doing a Data Cleaning and Error Handling video but its such a wide subject its taking some time to get the ideas together
@jonathanhammond5563
@jonathanhammond5563 3 жыл бұрын
@@JohnWatsonRooney that is amazing! I will definitely be learning from that one. Not sure if this helps, but my employer stumped me with three/four errors: - sometimes the page failed to go directly to the login. I wasn’t sure how to refresh the page and kept getting an infinite loop. - sometimes the error (basically a div) would appear immediately after logging in, before the “loading” sequence. This seemed again like a refresh might have been the solution. - occasionally after the “loading” sequence finished, an error would also appeared there. All three appeared to be reload related, but I wasn’t sure how to fix them. - finally, an “error” of sorts was when multiple elements had the same id. This was also by design simply to be a pain in the neck. Maybe some of those ideas will help! Either way, you’ve been a big help and I will tell many people about your channel now that I know about it and it’s amazing quality. Have a great week
@JohnWatsonRooney
@JohnWatsonRooney 3 жыл бұрын
@@jonathanhammond5563 thanks really appreciate the suggestions!
@EarlWallaceNYC
@EarlWallaceNYC 3 жыл бұрын
Great ! Thanks
@serageibraheem2386
@serageibraheem2386 3 жыл бұрын
Man thank you very much
@moeinht2713
@moeinht2713 2 жыл бұрын
I used selenium to click a page I need to use Chrome cache and cookies But Chrome works as a test software please guide me
@joshuamarcano350
@joshuamarcano350 2 жыл бұрын
Selenium is a nightmare to get started with. No solution is working for me.
@JohnWatsonRooney
@JohnWatsonRooney 2 жыл бұрын
It’s not very beginner friendly although very powerful. Check out my videos on helium and playwright - very good alternatives!
@renancatan
@renancatan 3 жыл бұрын
How do you actually starts to scrape after login with selenium, is that possible? And where is part 2 of this video? I'm looking for some login scrape content, however I'm having hard time with this link: kzbin.info/www/bejne/mYeVYniFm5qVmKM Because the request for login/security that I found in network is not working =/
@kiriakosdimtsis1016
@kiriakosdimtsis1016 3 жыл бұрын
Once you login in you can either scrape elements with Selenium or get the entire page source with driver.page_source because sometimes it's not visible if you use requests
@LordJuztice
@LordJuztice 2 жыл бұрын
*.find_element_by_xpath()* no longer supported in the latest version. you need to use *.find_element("xpath", ' ')* So it would instead look like *driver.find_element("xpath", '//*[@id="username"]').send_keys('tomsmith')*
@higiniofuentes2551
@higiniofuentes2551 2 жыл бұрын
Thank you for this very useful video!
How to SCRAPE DYNAMIC websites with Selenium
11:04
John Watson Rooney
Рет қаралды 175 М.
This is How I Scrape 99% of Sites
18:27
John Watson Rooney
Рет қаралды 208 М.
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН
Маусымашар-2023 / Гала-концерт / АТУ қоштасу
1:27:35
Jaidarman OFFICIAL / JCI
Рет қаралды 390 М.
SLIDE #shortssprintbrasil
0:31
Natan por Aí
Рет қаралды 49 МЛН
The most important Python script I ever wrote
19:58
John Watson Rooney
Рет қаралды 211 М.
Web Automation using Python To Fill out A Form
16:37
Rishab Kattimani
Рет қаралды 159 М.
Selenium Headless Scraping For Servers & Docker
16:22
NeuralNine
Рет қаралды 35 М.
Python Selenium Tutorial - Automate Websites and Create Bots
36:42
Tech With Tim
Рет қаралды 277 М.
Web Scraping for Beginners with Python and Selenium 4
21:22
The PyCoach
Рет қаралды 13 М.
The Biggest Mistake Beginners Make When Web Scraping
10:21
John Watson Rooney
Рет қаралды 123 М.
Stop Using Selenium or Playwright for Web Scraping
10:46
John Watson Rooney
Рет қаралды 14 М.
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН