Python Selenium Tutorial #2 - Locating Elements From HTML
Vložit
- čas přidán 27. 04. 2020
- In this python selenium tutorial I cover how to locate elements from a webpage. This will show you how to find elements from a selenium script using their ID, class name, name and other features. In this video we use selenium to search for something on a website then list out all of the search results.
Selenium Documentation: selenium-python.readthedocs.io/
Playlist: • Python Selenium Tutori...
Subscribe to my second CZcams channel for weekly podcasts: / @timeoutwithtim
◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python
tech-with-tim.teachable.com/p...
📸 Instagram: / tech_with_tim
🌎 Website techwithtim.net
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-ruscica-82631b179
📂 GitHub: github.com/techwithtim
🔊 Podcast: anchor.fm/tech-with-tim
💵 One-Time Donations: www.paypal.com/donate/?token=...
💰 Patreon: / techwithtim
◾◾◾◾◾◾
⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
⭐ Tags ⭐
- Tech With Tim
- Python Tutorials
- Selenium Tutorial
- Selenium Python
- Locating Elements Selenium
- Find Elements Selenium
⭐ Hashtags ⭐
#python #selenium #webscraping
Great tutorial!
for anyone following on 2022, the method find_element_by_class_name was deprecated, gotta use find_element(by=By.CLASS_NAME, value="element to look for")
oh thanks :)
man finding elements by class is returning the nosuchelement exception no matter how much i try
@@indicgamer2907 Try this: article.find_element(by=By.CSS_SELECTOR, value="div.entry-summary")
im getting an "unresolved reference" for that "By" in "By.CLASS_NAME"
@@adthn WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='search_query']"))).send_keys("youtube test")
driver.find_element_by_xpath("//button[@id='search-icon-legacy']/yt-icon").click() try this
How is this FREE CONTENT so much better than the course I'm following on Udemy or any tutorial I've seen on selenium out there? The answer: Tim is an outrageously excellent communicator, an aberration
He doesnt has to make this content paid since he wins money from visits..
every coding tutorial i see, people are just criticizing udemy lol
@@kshau_ it's bec the quality is poor compared with the price of the course
Which course are you taking?
Ansewer: free lessons are not worried of being super complete and well explained
You don't even know how useful these tutorials are... I've tried so many times to learn selenium, but there's no proper tutorials out there... until now!
Agreed ! And even less with python and selenium 👍
ya same very few tutorial on selenium i wanted to learn selenium 2 months back but due to less tutorials i dropped it but now i am learning from Tim.
This channel is simply fucking great
Check out in Udemy i have created a f/w using python and selenium
so hell true i was struggling trying to learn selenium until i found this channel
These tutorials are exceptional so clear and precise. Thank you Tim! I need to make an entire project and submit it by the end of May and this tutorial is helping me understand things tremendously! Please if you can finish the entire series within the initial weeks of May. And keep being awesome. Much Love.
You teach better than any teacher I have ever seen. For some reason, it is extremely easy to follow along with everything you're saying.
You earned a new sub forsure.
I would literally invest a fortune to get any of your courses. The way you explain stuff just blows my mind! I can never be thankful enough for all of this!
I am struggling to become an hybrid tester, being a functional QA for over 8 years but your videos are really helping me a lot to achieve my goal in order to grow further in my IT career! THANKS!!!
Ive been trying to use chatgpt for a selenium project, but looking the descriptions on this series I'm delighted to go throughly through all these tutorials so i may actually get this project of mine done. Thanks so much for being consistent and thorough in your tutorials.
Several times I got myself stucked in minor mistakes using Selenium, sometimes mine, some from the books, and here made it so easy to follow.
Have my subscription and my Like, Sir.
Your the best python tutor ive seen. Seriously great detail, the use cases are helpful as well, everything. top notch.
I consider that Tom is one of the best teachers in computer science that I´ve watched. Please continue by explaining different topics in python. Thanks
tom?
Great tutorial for Selenium. It's important to note that Selenium is very slow, and for any large scale project, it would take minutes (sometimes hours) to finish running, so this web scraping approach should be the last option to be used for websites with heavy JavaScript. The practical approach would be to send a GET request to the URL of the website and adding the search query to the end of the URL and then parsing the response. You can see at 5:30, the URL has the query add "?s=test". This is the same approach but maybe 100 times faster than using Selenium.
What is the name of this practical approach, or are there any tutorials you can refer me to? I've realised this selenium tutorial is great but not practical for a site with large scale data
@@danfog7370 regular webscraping using requests
That can be very hard at times though. As most websites tend to obfuscate these kind of things.
Yep. It's easy to use with websites that deliberately obfuscate how they work to prevent automatic interaction, though. For example, I wrote a simple API to upload and download photos from and to Amazon Photos, which really doesn't work by using normal requests.
@user-bg2pl1we7x you mean that you wrote a simple *script*. Not an API. An API is literally what requests work through.
This is exactly what I was looking to understand web scraping. Amaizing tutorial! Thanks so much for sharing it.
Probably one of the best Python tutorial channels on CZcams
I went through this video twice because the material has been so useful. Thank you again!
Thank you Tim for complicating things in the end of the video, making it even more challenging to understand.
Awesome Tim. As for the headers I used this line
header = article.find_elements_by_tag_name("a")[0]
then
print(header.get_attribute('innerText'))
Congratulations on the video. Keep bringing us more of those on Selenium. Especially regarding most common errors such as Stale Element Reference Exception and No Such Element. It could be very helpful.
Looking forward for more selenium tutorials 👏
www.udemy.com/course/learn-selenium-automation-in-easy-python-language/learn/lecture/16983696?start=1#overview
Thank you Tim for this, looking forward fof more
Thank you!
NEVER STOP MAKING THIS CONTENT IT IS EXTREMELY VALUABLE THANK YOU SO MUCH FOR EXISTING
Dear Tim, OMG WOW! This is a life changer!!!
With this, anything is possible.
THANK YOU!
Hey man
I just wanted to say: you have the gift of simplifying complex things. God Bless You.
If i have a moral to tell anyone about learning tutorials: "Don't just pause the video and go faster than Tim i literally spent half an hour trying to figure out an error that Tim was just about to explain 😂 " : 8:40
i did the same lol
haha same
you are not the only one
That's relatable
I actually did that even AFTER reading your comment and got stuck for like 10 minutes without understanding why it wasn't working xD.
Tim is the GOAT. Easily on par with the UMich courses on coursera (but where they teach you the language, he gives these awesome tutorials to show what you can really do with it).
Thank you, thank you, thank you for this tutorial! You explain things very clearly! I hope you keep on making these videos!
Love your tutorials, this one really helped me out starting up with selenium
Great new tutorial! You're just awesome man and I've earned so many coding skills from you!!!
Hello Tech with Tim, your Selenium python tutorial is amazing it gave me an way better understanding then documentation. Thanks for the tuturial.
appreciate you man I have so many ideas for how I'm going to use what I learned, so much practical info.
Best Programming CZcamsr Ever!!!!
Thanks for your Tutorial Tim.. Very Understandable Thanks!!!
frankly speaking ,Tim is just an amazing teacher
Thank you for this. Im looking forward to all the parts of this series
Amazing tutorial, everything worked perfectly. Thank you!
you are doing a great job Tim! Thanks a lot for your efforts!
Please keep up the good work. Following this series!
Very useful tutorial, thanks a lot!
THANK YOU for these videos!
Highly appreciated videos!
Amazing job. Learning from you is surprisingly easy
Good content, thanks for putting your time and effort into this. Definitely worth a like
It's been a while I came across a good tutorial. Thanks !!
i rarely subscribe but your contents are very concise and technical, that i had to subscribe; more power to your channel.
this playlist is dope! thanks bro, cheers from france
The difference betwn "find_element" and "find_elements" is single item vs list
Bro, I had no idea why my code wasn't working. Thank you!
Thnx for mentioning, couldn't find the send_keys().
THANK you!!! Great clarification :)
thank you man, i was getting error like 'list' object has no attribute 'send_keys'
thank you brother
Incredibly helpful, thank you tim
You are amazing!!! Normally I don't like to write comment but I just want to support you. Thanks a lot
Btw, there is a "main" ID on the first page too, and for me it got that instead of the second page.
It's an easy fix, just put time.sleep(5) a few lines before the try statement.
Amazing, thank you so , so much! It works like a charm every time.
Wow, this video provided the help I´ḿ looking for to resolve some work issues. Thanks!
Thank you for teaching this on free.
Love you😍😍😍😍
Awesome explanation and great contents, liked and subscribed!!
All I wanna say is...THANK YOU SO MUCH FOR THESE VIDS
starting a new job, and you are a godsend!
You rock Tim, great work!
Just remember that you have to type find_elements_by_class_name etc. because there could be more than one of the same class name. Typing find_element_by_class_name etc. will throw an error.
Many tnx Tim. U r doing perfect work. Can you please consider talking about preprocessing datasets like NELL.
I love your videos! so detailed!
AWESOME video waiting for the next one !!!!!!!!!!!!!!!!!!!!
Thanks for such a great tutorial it's simple though very useful
This video is better than so many paid courses!
man I love your video gonna make a bot to attend my online classes with this, thanks dude 😉😉
Thank you so much for this tutorial!
You are an amazing teacher!
Please update the video for the new code
i think the titles weren't printing because they were nested inside an anchor tag. you would have to add a line to find by tag name "a" for each "entry-title" and it would have printed. You are a great teacher Tim.
This tutorial is incredible.
Really helpful! Keep it up!
This is great. You're the best
Thanks for your efforts Tim
Amazing tutorials for selenium .... Thanking you
With regards,
Indian Tubers
Only subbed cause you came in my reccomendations, love programming and am named Tim
Great job Tim! Recent subscriber and happened to see the start of this series recently. Trying to watch 1 video of yours before work (2nd shift ugh). I love Python as well. I was wondering if you could do a Go tutorial series if you get time please? Especially since it's newer and that you are good at teaching. Thank you.
Ya id actually love to do go! Definitely on my list
Really helpful. THANKS👍
Tim, You are the best.
Thank you so much! Subscribed!
Nice.. Please by the end of the series, discuss about the difficulties and dependencies on collecting data from dynamic websites and SPA.. Please that would be really beneficial.. And I appreciate your effort.. Thank you so much!
Beacuse for example: sometimes some websites shows valid src in img tag but after scrapping with selenium they become dummy like DATA:jsoockepskfuoe......== something
I didn’t find the issue yet
awesome tutorial. tyvm bro!
@Tech With Tim, The glitch you are talking about (7:00) is the opacity for the entry-title class is 0%
.entry-title {
color: orange;
opacity: 0%;
}
Excellent job. Congrats
Tim, Thank you for this course. However, when I try to pull the content from the search, my driver and content continue to pull text from your home page opposed to the updated search page content. It is as if the driver is not updated to the new page. Any help would be appreciated. I am using Firefox driver, if that makes a difference.
3:27 Notice we have both “find_elements_by_class_name” and “find_element_by_class_name”. I suspect what you said earlier about only finding the first instance of an element with a specified class applies to the latter call, not to the former; the former one would let you iterate through them all.
Thank you so much Tim I really Appreciate your time, help and effort. I have seen all of your tutorials in every section of SDET that was amazing and understandable.
I just wanna know about the name of application that you are working in this video, wanna start practicing by watching your video and try with myself.
Thank you !!!
Thank you for your series
said it before, gonna say it again: BOSS!
Hi Tim, what are you using for autocomplete in sublime text for python? That is showing you diffrent functions that you can use.
Excellent!
Men I wish all of my teachers explain my classes as you
Super super awesome and helpful 😊😊😊
I don't know how else to say this, I love you.
Thanks Tim!
please bro i am waiting for you to arrange the playlist. U teaches very well bro. I am from india and i loved the way u explain
Hi Tim! Thanks for the awesome videos I’m a new subscriber and love the content. I have a question: is it more efficient to grab a section like this and iterate through it, or would it just be better to select all of those articles headers text using 1 line xpath? Perhaps you showed it this way in case we want to extract more data than just the headers?
Also, I find myself using web driver wait on almost all element location to ensure I am waiting for DOM. Is this correct? Seems like code redundancy. (Figured out how to solve this part in part 6!)
Thank you so much!
Wow, great tutorial
Thanks Man!
You are the absolute man . . .
For some reason my chrome browser quits when it is opened through Selenium even if there is no quit command. Can someone help me fix this?
Hey Tim, @3:21 you show selenium completions in Sublime but I am not getting any of those. How did you set that up? Great videos, thanks.
Keep doing this!!!
THANK YOU!
Great content!