Python Web Scraping with Beautiful Soup and Regex

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024

ความคิดเห็น • 278

  • @cetrusbr
    @cetrusbr 6 ปีที่แล้ว +457

    I like your tutorials because u go directly to the content, something rare in youtube these days...

    • @kalef1234
      @kalef1234 5 ปีที่แล้ว +19

      Hey guys what's up before we get started smash that subscribe button, like this share it i am giving away a fucking gift card follow the links to my merch watch my ads really helps thanks okay...roll that intro *45 second intro*

    • @sourabhch3044
      @sourabhch3044 3 ปีที่แล้ว +2

      So true thank you for putting out the points which matters.

  • @mixalismcgamer3188
    @mixalismcgamer3188 4 ปีที่แล้ว +19

    Dude i watched over 15 videos+ that was recommended and after hours i found this FULLY EXPLAINED.

  • @kalef1234
    @kalef1234 5 ปีที่แล้ว +13

    I felt so powerful as soon as I pulled an array of strings from a random website. Thank you for your great tutorial

  • @zigginzag584
    @zigginzag584 4 ปีที่แล้ว +2

    It helps so much to have someone that matches your personality when learning stuff.
    I can't stand when asking someone for instructions on how to do something and they tell me everything
    that I can expect and every once i a while throw in the thing I'm supposed to do next.
    None of the fluff here. Just context. Every other creator would/has made this subject a 45min+ video
    but here I am feeling proficient after just 14 minutes with EM.
    Thank you, Sir!

    • @EngineerMan
      @EngineerMan  4 ปีที่แล้ว +1

      You're welcome buddy!

  • @kurdmajid4874
    @kurdmajid4874 3 ปีที่แล้ว +2

    he makes it so quick and simple

  • @dilshand.5127
    @dilshand.5127 6 ปีที่แล้ว +14

    I was able to do this on another leaderboard site, appreciate your work here.

  • @justinhamilton8647
    @justinhamilton8647 2 ปีที่แล้ว +1

    Cheers man i used this tutorial to sort through 310000 embed links you’re so awesome

  • @mhalton
    @mhalton 2 ปีที่แล้ว +1

    13:52
    Happiest man!

    • @EngineerMan
      @EngineerMan  2 ปีที่แล้ว

      Oh god I'm not gonna be able to unhear that any time soon.

  • @PS3PCDJ
    @PS3PCDJ 6 หลายเดือนก่อน

    This is THE best beautifulsoup tutorial on the internet.

  • @bhumikakhiyani4230
    @bhumikakhiyani4230 4 ปีที่แล้ว

    I was struggling to navigate to iterate through second span tag in multiple td tags I.e. (tr[1:]/td[0]/span[1])
    I was trying it the whole day.
    This is the best tutorial I have seen.
    Thank youuuuu.

  • @CODTALES-KILLSTREAKS
    @CODTALES-KILLSTREAKS 5 ปีที่แล้ว +2

    Hey man! I watched this and applied the concepts to a weather site and made a csv of all the sunset / sunrises in 2019! Thank you! Please I love the way you explain things keep making videos sir! I have applied your teaching in a couple videos and it’s great! Learning so much!

  • @xrefor
    @xrefor 5 ปีที่แล้ว +10

    Love this presentation. Straight to the point with short and specific explanation. Keep it coming! :)

  • @enyoc3d
    @enyoc3d 5 ปีที่แล้ว +3

    in a sea of youtube tutorials yours is the pearl. thanks!

  • @robertpearson2143
    @robertpearson2143 6 ปีที่แล้ว +2

    Been doing something similar for a while but in a much more complicated way. Looking forward to making my life much easier. Thank you!

  • @YeeYeez
    @YeeYeez 5 ปีที่แล้ว +2

    If only I had this tutorial a few years back. Good stuff.

  • @SusiEzhil
    @SusiEzhil 5 ปีที่แล้ว +7

    wow.. thats the crisp explnation,,, you're the man!!

  • @worsethanjoerogan8061
    @worsethanjoerogan8061 5 ปีที่แล้ว +1

    Dude you're helping me out immensely with computer science courses

  • @estilen69
    @estilen69 6 ปีที่แล้ว +9

    Using CSS selectors is the way to go, gets rid of nested for loops and is more robust.

  • @yanggao4878
    @yanggao4878 3 ปีที่แล้ว

    Your videos are fast-paced and straight to the point. Thanks!

  • @ViniciusProvenzano
    @ViniciusProvenzano 3 ปีที่แล้ว

    Real Nice content! Straight to the point. I’ve played around with beautiful soup a few years ago for an small project, and I just wish this video was around at the time....

  • @rustyelectron
    @rustyelectron 6 ปีที่แล้ว +1

    This video is really a good intro to web scraping.

  • @ladyViviaen
    @ladyViviaen 4 ปีที่แล้ว

    was trying to scrape modarchive for my project, this is way better than writing the name and id down by hand lmao, thank you!

  • @johnbecker3116
    @johnbecker3116 6 ปีที่แล้ว +11

    I spent forever teaching myself this last week and now you post this. Kill me now

  • @Lu3ck
    @Lu3ck 5 ปีที่แล้ว +2

    Your videos are fast but glorious! Love your content man! Thank you! Bless 🙏

  • @susbedoo
    @susbedoo 5 ปีที่แล้ว +1

    You are the coolest tech guy I have ever seen on TH-cam

  • @TomSilver_42
    @TomSilver_42 3 ปีที่แล้ว

    Simply brilliantly explained. I have seen few of your videos and I like your style, therefore You have earned another subscriber.

  • @impossible441
    @impossible441 6 ปีที่แล้ว +1

    This is remarkable, very informative and down to the earth - I really love this concise format of yours which is rather contradictory to what most of ppl on yt are providing

  • @chowfatt38
    @chowfatt38 6 ปีที่แล้ว +52

    Great video again. I've been playing web scraping a while and I find that most of websites nowadays using javascript rendering quite heavy. Will you make a part 2 for talking about how to web scrape javascript rendering website? And what do you think about another web scraping package, Scrapy? thanks Man

    • @poidog22
      @poidog22 6 ปีที่แล้ว +2

      This would be a great follow on. +1

    • @cruzab3153
      @cruzab3153 6 ปีที่แล้ว +2

      Selenium is good and easy....

    • @trailrider6844
      @trailrider6844 5 ปีที่แล้ว

      +2

    • @tayfun6378
      @tayfun6378 4 ปีที่แล้ว +1

      puppeteer does a good job these days I think

    • @Megaloplex
      @Megaloplex 3 ปีที่แล้ว

      +100

  • @ledosilverknight4619
    @ledosilverknight4619 6 ปีที่แล้ว

    Some of the best tutors are always straight-forward: down and dirty!

  • @kennethmcquade4341
    @kennethmcquade4341 5 ปีที่แล้ว

    You're definitely skilled! For anyone watching these videos, don't get discouraged, this takes time. @Engineer Man , Can you talk about the experience of learning how at the beginning of your videos?

  • @clownboy84
    @clownboy84 5 ปีที่แล้ว +1

    Thanks for the video. I like how you take the basics and break it down with really good and practical examples.

  • @EluviumMC
    @EluviumMC 6 ปีที่แล้ว +6

    Happy that you've chosen this topic. I've been exploring web scraping and have a script that works pretty well on a site that I frequent. Another awesome tool that can be used to also automate web navigation is the selenium package. But on more of a question-related note, I know the script you just made was pretty simple, and the one I have isn't that complicated, but I've been wondering how one would go about writing an object-oriented script for scraping?

    • @UchihaAditya
      @UchihaAditya 6 ปีที่แล้ว

      What are the advantages of selenium over Beautiful Soup?? I have a web-scraping assignment now and was advised to use selenium.

    • @EluviumMC
      @EluviumMC 6 ปีที่แล้ว +2

      Selenium can be used as a web scraper, but I use it more for web navigation and then use beautiful soup to actually get the data I need from the pages once they've been navigated to. I just find beautiful soup to be a more intuitive for extracting the data.

    • @yixunnnn
      @yixunnnn 6 ปีที่แล้ว

      With selenium it is like an automated user, and when you use it, you require a web driver, and you can choose if you want the automated browser to run in the background or not. I recently used selenium because I was trying to request for content behind a microsoft login page, which is loaded using javascript, thus I needed to wait till the content was actually loaded finish before i submit anything. Unlike requests, which instantly retrieves the page content.

  • @arturmangabeira9990
    @arturmangabeira9990 6 ปีที่แล้ว +1

    EM you're awesome. i was studying web scraping and this come up. subscribed yesterday to your channel! lol

  • @Omar-ic3wc
    @Omar-ic3wc 4 ปีที่แล้ว +3

    Exactly what I needed thank you very much!!

  • @legioner304
    @legioner304 6 ปีที่แล้ว +2

    3 searches in the loop - very dirty )
    "The speed of software halves every 18 months"

  • @laxlyfters8695
    @laxlyfters8695 6 ปีที่แล้ว +8

    Went through a 30 second hillshire farms ad. Great match youtube

    • @EngineerMan
      @EngineerMan  6 ปีที่แล้ว +13

      Google knows you're into web scraping and sliced turkey lol.

    • @laxlyfters8695
      @laxlyfters8695 6 ปีที่แล้ว +1

      Engineer Man no lie came back and got an ad for $3 jack box munchie meals. TH-cam thinks your fans are stone while watching your videos

  • @DrSarge37
    @DrSarge37 6 ปีที่แล้ว +14

    It would be cool to see how to deal with pagination. So you want data from /page=1, /page=2 etc. Etc.

    • @joefagan9335
      @joefagan9335 4 ปีที่แล้ว +4

      In your browser go to next page and copy the url of, say, page 2 and go to last to find the last page url. Use that as a template to build the url of each page you want. Loop over them in turn.

    • @joefagan9335
      @joefagan9335 4 ปีที่แล้ว

      John Keymer nope you’re not parsing the page a second time to find the next button. You scrape the current page and then grab the neat page by creating the string for the next url and accessing the next page - just one grab per page.

  • @qettyz
    @qettyz 5 ปีที่แล้ว +3

    These were really good examples, thank you!

  • @asdfasdfasdf383
    @asdfasdfasdf383 4 ปีที่แล้ว

    You go straight to the point. Obviously, you know a lot more in-depth about this topic. Anyway, I like it.

  • @stephenrochester6309
    @stephenrochester6309 5 ปีที่แล้ว +1

    These videos are brilliant. Thanks for all your hard work.

  • @axelcano1623
    @axelcano1623 6 ปีที่แล้ว

    Really nice content! You explain just enough to be clear but not too much that's perfect. Please continue to remind the type of the elements you create, it's very important for beginners.

  • @ddmin3082
    @ddmin3082 6 ปีที่แล้ว +10

    Awesome video! Can you do one on the requests module please?

  • @oromis995
    @oromis995 3 ปีที่แล้ว

    This content is absolute gold.

  • @0xBerto
    @0xBerto 4 ปีที่แล้ว

    Hey, question. Your python craigslist scammed video. Why turn off comments? I had questions. Now I’m in another video to ask about it. Basically just wanted to know if the person who’s DB you tried to flood would be able to just delete all post made from your IP address?

  • @kristiyangerasimov6708
    @kristiyangerasimov6708 3 ปีที่แล้ว

    Great video. Stuff like that makes me want to program and develop software until i die.

  •  5 ปีที่แล้ว

    What editor are you using for python? I’m a newbie. Thanks.

  • @PriZ0nM1ke
    @PriZ0nM1ke 6 ปีที่แล้ว

    Wow these videos are awesome! Direct and concise but understandable!! Well done!

  • @blevenzon
    @blevenzon 6 ปีที่แล้ว +1

    Wow just found your channel by accident and I’m loving it. Awesome content!! Do you think you can do a vid on Elastic Stack?

  • @K2ThaYo
    @K2ThaYo 6 ปีที่แล้ว +1

    Beautiful video man! Really valuable information here. As a sysadmin with over 10 years experience, I can state its really clean method of scraping. I was used to use bash scripts for everything but using libraries in python is sooo helpful. It would be a pain in the as in bash with awk, grep, etc. I hope to see more soon

  • @DirtySocrates
    @DirtySocrates 6 ปีที่แล้ว +2

    Excellent! Thank you!! Great vid!

  • @grantfaith
    @grantfaith 3 ปีที่แล้ว

    ty, saved me an hour of time from all these other videos. holy shit

  • @andriybortnik8310
    @andriybortnik8310 6 ปีที่แล้ว +2

    This is an awesome video, I actually enjoy the in depth walk through of what your reasoning behind writing code is, step by step. Versus just saying " I did this" and not really explaining anything. On a separate note , I'm looking to get into python, and I have previous code development experience, but It's been a little while, and setting up an environment to start doing some coding is a bit daunting. I'm looking to do more on the machine learning , neural networks side of things. I don't struggle with any of the logic, mathematics, but I know there are many pros/cons of various IDE's . Some have better support for various packages , etc.. I was wondering if you could either make a video on some of this information, or maybe throw a few pointers my way. I would really appreciate that. Otherwise, keep up the great content!!!

    • @KingEbolt
      @KingEbolt 6 ปีที่แล้ว +3

      Let me throw some pointers at you.
      0x3A738216
      0x6B321970
      0x88AC172B

    • @EluviumMC
      @EluviumMC 6 ปีที่แล้ว +3

      I've found that I really like using Microsoft's VS Code (not to be confused with Visual Studio). The IDE has a good clean interface, lots of extension support, and a built-in terminal.

    • @andriybortnik8310
      @andriybortnik8310 6 ปีที่แล้ว +1

      @@KingEbolt I can't even get mad at that... Well done

    • @camaulay
      @camaulay 5 ปีที่แล้ว

      @@EluviumMC +1 VS Code, switched from Sublime

  • @JoseGarciam4t0n
    @JoseGarciam4t0n 5 ปีที่แล้ว

    Hey, I really love your videos man! How about elements within elements, so for example `this link is in a paragraph`. How would you approach that?

  • @royslapped4463
    @royslapped4463 2 ปีที่แล้ว

    this is perfect for what I needed thank you!

  • @alfredleppanen6796
    @alfredleppanen6796 4 ปีที่แล้ว

    Hey great video! Lets say in your last leaderboard example, I would like to get notified when the leaderboard has changed, so to say when something changed on the site. I have built a script where I can see the HASH change, but I cant output what actually changed on to website, do you have any tips to how to monitor what actually changed on the website?

  • @virtualize2424
    @virtualize2424 3 ปีที่แล้ว

    How do you scrape something like TH-cam comments (without using TH-cam api)? When I get the html data for a video using requests library, the video's comments are not their in the html data.

  • @TheEndermanMob
    @TheEndermanMob 3 ปีที่แล้ว

    How does he knows a lib for everything? i'am addicted to his videos.

  • @molimola3
    @molimola3 5 ปีที่แล้ว +2

    Hey I love you videos ! You explain everything so well. I am trying to scrape some websites but they don't allow me because of their bot protection... Do you have any tips about this ? Thanks

    • @сашарассадин-щ5ъ
      @сашарассадин-щ5ъ 5 ปีที่แล้ว +2

      I got this problem too. In my case I have solved that by changing a type of my request, now it includes *headers*.
      You need to look up for the data of your headers in your web browser. You should visit google.com page, press ctrl+shift+I, in opened console find "network", and search necessary elements there.
      In in the other words, the solution is adding "headers", I hope the information will help you.
      Example:
      headers = {"accept" : "your accept symbols",
      "user_agent", "your user agent string"
      session = requests.Session()
      request_variable = session.get(url, headers)
      P.S. I am from Russian, I was not using a translating while typing it, I hope you were able to understand me.

  • @supalistmain4882
    @supalistmain4882 6 ปีที่แล้ว

    @Engineer Man , what is your day job? And how did you get into coding? Do you have a CS degree? and.... well instead of more questions, rather just ask whats your background (ito what lead to you adding so much value with these vids)?

  • @wilkinsanchez8737
    @wilkinsanchez8737 6 ปีที่แล้ว

    Amazing video. How did you decide to select 0,1,3 on your code. For example, on line 14,15,16. place = tr.find_all('td')[0].text.strip() why the Zero, One and Three?

    • @defau1tMC
      @defau1tMC 5 ปีที่แล้ว

      Because tr.find_all('td') returns a list of tds in each tr, the 0, 1, and 3 correspond to those entries in the list

  • @DrChrisCopeland
    @DrChrisCopeland 5 ปีที่แล้ว

    how would you modify this for nested div elements in place of table row and cell elements?

  • @metaphysicalconifercone182
    @metaphysicalconifercone182 6 ปีที่แล้ว

    Do you know any website or application that gives this sort of challenges? I have mostly learned python but in practice still don't know what to do with it yet.

  • @Ashesoftheliving
    @Ashesoftheliving 5 ปีที่แล้ว

    Hey E-man Great video! I wanted to ask you this. You said that "you have to know the structure of html before doing scraping from websites" which is true but I need to create a process where I can search a keyword or basically a word on multiple websites and get the content out of those websites. Now from this content, I will create a sentiment value and generate a newsfeed in my application with a sentiment value in it. Can you suggest a way I can do that?
    Thanks in Advance

  • @chrisabreu7469
    @chrisabreu7469 6 ปีที่แล้ว

    your videos are a life saver man. keep up the great content

  • @treybailey6752
    @treybailey6752 6 ปีที่แล้ว

    Great vid with fantastic content. Would love to see this where you first login in order to get content. Getting the headers set is a challenge.

    • @EluviumMC
      @EluviumMC 6 ปีที่แล้ว

      Using Selenium to do the site navigation to get you logged in is how I worked around getting into a site that requires login credentials prior to scraping.

  • @FreeDomSy-nk9ue
    @FreeDomSy-nk9ue 3 ปีที่แล้ว

    How do I combine this with Login? For example, I want to log into my TH-cam account and scrap data from my favorite videos url.

  • @syntaxis5584
    @syntaxis5584 5 ปีที่แล้ว +1

    why did you use 'View page source' instead of 'inspect' to find the page structure?

    • @EngineerMan
      @EngineerMan  5 ปีที่แล้ว +2

      I did it because view source represents the content that was delivered to the browser on load whereas inspect represents the content currently on the page. Since the scraper doesn't see anything dynamically generated, view source is best.

  • @donaldandmijung
    @donaldandmijung 2 ปีที่แล้ว

    great tutorials! do you have a tutorial on scraping with a function( ) using beautiful soup

  • @JeanDAVID
    @JeanDAVID 5 ปีที่แล้ว

    I have difficulties to soup data with some tags in HTML files like . I use soup = BeautifulSoup(myfile, 'html.parser') and all the link tags turned out to be tranformed to . How come

  • @Viruhemanth
    @Viruhemanth 5 ปีที่แล้ว

    carefully he's a hero

  • @bennieliu3261
    @bennieliu3261 6 ปีที่แล้ว

    Awesome tutorial man! Can I suggest scraping dynamic pages as the next tutorial. Would be a sweet follow up

    • @EngineerMan
      @EngineerMan  6 ปีที่แล้ว

      Thanks. Part 2 of this is being requested a lot, I need to see what is best to do.

  • @LarsHolmVV46
    @LarsHolmVV46 4 ปีที่แล้ว

    That was beautiful not to say absolutely excellent. Man ,,,,,

  • @zenmaster24
    @zenmaster24 6 ปีที่แล้ว

    awesome vid! :D
    how would you do it with a site you need to be logged in to?

  • @luis96xd
    @luis96xd 4 ปีที่แล้ว

    Wow, I liked this video so much! It was very useful! 😄
    You really have helped me a lot, it was well and fully explained, with real life examples
    Thank you so much for this tutorial! 👏👏

  • @daltonkraklan2257
    @daltonkraklan2257 2 ปีที่แล้ว

    This was so freaking helpful

  • @ilobuhabib8325
    @ilobuhabib8325 ปีที่แล้ว

    love your tutorials.
    I tried following your method to scrape a site, but the output is empty. when I checked the 'tr' throughout the source code, it has values, but I do not understand why the output is empty.

  • @bollingeralx
    @bollingeralx 5 ปีที่แล้ว

    What's up man! Question what is data scrapping used for?

    • @soldiergaming2722
      @soldiergaming2722 5 ปีที่แล้ว

      For gathering data.... For research or whatever you wanna do with it.

  • @DevastaingDj
    @DevastaingDj 6 ปีที่แล้ว

    Awesome! Kudos! Very helpful. Thanks man!

  • @elliottharris7496
    @elliottharris7496 3 ปีที่แล้ว

    This was a pro tip on how to eat a t-rex 10:47

  • @xppaicyber3823
    @xppaicyber3823 4 ปีที่แล้ว +1

    Great content

  • @malharjadhao1934
    @malharjadhao1934 4 ปีที่แล้ว

    Which operating system are you using ?

  • @NokiaN8Guides
    @NokiaN8Guides 5 ปีที่แล้ว +3

    thank you so much for this amazing tutorial, i would like to ask what do we do if the site i want to scrap require to be logged in btw this got recap

    • @joefagan9335
      @joefagan9335 4 ปีที่แล้ว

      Usually, you can login first. Leave it open in your browser and scrape away.

  • @kylemichaelreaves
    @kylemichaelreaves 3 ปีที่แล้ว

    Super helpful, thank you.

  • @BrettKromkamp
    @BrettKromkamp 5 ปีที่แล้ว

    Excellent tutorial. Thanks.

  • @santiagorivera1562
    @santiagorivera1562 5 ปีที่แล้ว

    What is the advantage to using Beautiful Soup over other webscraper packages with Python?

  • @recitoprasidha5761
    @recitoprasidha5761 5 ปีที่แล้ว

    but how do we scrape the nowdays web that uses javascript framework that if we look at "view page source" we dont see html tag anymore. bcause it is wraped already with js

  • @JDRudie-ec4xq
    @JDRudie-ec4xq 5 ปีที่แล้ว

    what auto complete package are you using for atom?

  • @Zua0man
    @Zua0man 5 ปีที่แล้ว

    What skills would you say are required when performing the scrapping?

  • @haynej3
    @haynej3 6 ปีที่แล้ว

    Is there an equivalent parser for web scraping that you recommend or are aware of for ruby?

    • @EngineerMan
      @EngineerMan  6 ปีที่แล้ว +1

      Try nokogiri.

    • @haynej3
      @haynej3 6 ปีที่แล้ว

      Thanks!

  • @princepeach_
    @princepeach_ 4 ปีที่แล้ว

    I have an issue though, I’m web scrapping my stats from a website and when my stats update the webscrape doesn’t update it.

  • @staynjohnson4221
    @staynjohnson4221 4 ปีที่แล้ว +1

    The website ( umggaming.com/leaderboards ) now has cloudflare causing the request.get() to give 503 status_code. any solution to this ?

  • @JeroenTrappers
    @JeroenTrappers 6 ปีที่แล้ว

    Good video. Personally, i like using node with dom module and write css queries to extract what i want.

  • @ne12bot94
    @ne12bot94 5 ปีที่แล้ว

    Just wondering is there way to filter it and remove all the garbage that they send back? Idk?v😐v

  • @magicyvan
    @magicyvan 2 ปีที่แล้ว

    loved it ! Efficiency and very clear for a beginner. Would be great to have the login part, and why not sending the extraction into a csv file ;) I subscribe ;)

  • @siloenoah
    @siloenoah 6 ปีที่แล้ว +4

    Teach me your ways

  • @bed781
    @bed781 3 ปีที่แล้ว

    Is there a scraping method that can read the javascript content generated?

  • @affezippel7214
    @affezippel7214 3 ปีที่แล้ว

    is there somebody who did extract the data of the golf website, like getting all the names, numbers and emails of the club contacts but without regex instead using beautiful soup? I'm stuck there and would appreciate some help. I also wrote my problem in the EM discord channel in python

  • @nicememe999
    @nicememe999 6 ปีที่แล้ว

    Yes! A great tutorial on web scraping! Now I got some ideas on some websites I could scrape for data...
    What kind of real-world applications could this be used for? With websites providing APIs with the data nicely packaged in JSON format, it seems like getting data via APIs seems to be the better (or at least the most common way) to do this. Are there any situations where web scraping would be better?

    • @impossible441
      @impossible441 6 ปีที่แล้ว

      I guess that any kind of scientific literature databeses use webscraping (i.e. google scholar)

    • @EluviumMC
      @EluviumMC 6 ปีที่แล้ว

      Webscraping should be a last resort. Getting data via an API is much better.

  • @MrFrondoso
    @MrFrondoso 3 ปีที่แล้ว

    Génial. Dieu sait que je galère à utiliser BSoup . Et là j'ai l'impression d'avoir enfin compris.

  • @socksincrocks4421
    @socksincrocks4421 4 ปีที่แล้ว

    Thank you for your video. Awesomesauce