You Should Use CSS Selectors for Web Scraping.

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ต.ค. 2024
  • Lets talk CSS Selectors. I demo the most common, and most useful ones to help you extract data using your web scrapers as easily as possible. I'm using requests_html in Python, which can be pip installed if you do not have it already. It's a great libary and well worth learning
    -------------------------------------
    Disclaimer: These are affiliate links and as an Amazon Associate I earn from qualifying purchases
    -------------------------------------
    Digital Ocean (Cloud Servers, Affiliate Link) - m.do.co/c/c7c9...
    Sound like me:
    microphone amzn.to/36TbaAW
    mic arm amzn.to/33NJI5v
    audio interface amzn.to/2FlnfU0
    -------------------------------------
    Video like me:
    webcam amzn.to/2SJHopS
    camera amzn.to/3iVIJol
    studio lights amzn.to/3aBpKik
    small lights amzn.to/2GN7INg
    -------------------------------------
    PC Stuff:
    case: amzn.to/3dEz6Jw
    psu: amzn.to/3kc7SfB
    cpu: amzn.to/2ILxGSh
    mobo: amzn.to/3lWmxw4
    ram: amzn.to/31muxPc
    gfx card amzn.to/2SKYraW
    27" monitor amzn.to/2GAH4r9
    24" monitor (vertical) amzn.to/3jIFamt
    dual monitor arm amzn.to/3lyFS6s
    mouse amzn.to/2SH1ssK
    keyboard amzn.to/2SKrjQA

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

  • @mohitkumar-tv5ye
    @mohitkumar-tv5ye 3 ปีที่แล้ว +3

    You make one of the best tutorials mate. you simplify it and explain it so well, can't thank enough. Keep it up buddy :)

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

    This is gold. I’ve watched so many of your vids but missed the foundational stuff like this. If I’m ever in the UK I’ll have to buy you a beer!!

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

      I don’t yet work professionally as a developer, and while I really enjoy scraping I wonder if I’m pursuing a route that has a low pay ceiling.
      If anyone has any opinions on that I’d love to hear.

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

      Learning web scraping is a good way to teach you skills that will transfer over to any web related job - keep learning until you find what it is you want to do, even if that’s not a tradition dev job. There is money to be made with scraping data but taking those skills and building web apps that connect other software via an API is a good place to look

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

    Great video! Would be great to have another video comparing CSS and Xpath. Differences in their time performance, generality, compatibility with browsers and etc.

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

    The most informative and concise video on this topic! Thanks again John.

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

    Fantastic overview. Thank you much!

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

    Best video on css selector

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

    Thank you for this very useful video!

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

    so easy to follow thank you

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

    Amazing! A cheatsheet would be appreciated too

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

    This is a dilemma for me. CSS selectors seem much easier to read and are more straightforward, but XPath seems a lot more powerful for selecting exactly what you need within complex nested tags. I guess it works to mix and match though, like use CSS by default and switch to XPath when I can't get what I need with CSS?

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

      I’ve always got by with css selectors. I learned them well when I first looked into scrapy as they were in most of the documentation. It’s absolutely fine to use whichever whenever as long as it works for you and you get the results you want!

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

      @@JohnWatsonRooney Thanks John! Between your channel and a Udemy course I got on sale, I'm getting the hang of this stuff quicker than I thought. You're definitely the go-to resource on TH-cam. Kudos and keep it up!

  • @mattmovesmountains1443
    @mattmovesmountains1443 3 ปีที่แล้ว +1

    This is huge. I spend the most time trying to grab the correct elements, rather than the actual logic of the code, often coming up with None types. This is going to be my new reference guide

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

      @Shepard Kingston this reminds me of the time I went to the grocery store and one of the aisles had Spam in it

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

    thanks for making simpler

  • @tubelessHuma
    @tubelessHuma 3 ปีที่แล้ว +1

    I like your video 👍 xpath seems easy than css. Which is the best option?

    • @JohnWatsonRooney
      @JohnWatsonRooney  3 ปีที่แล้ว +1

      I prefer css as I am more used to it. However once you learn xpath properly you can do some cool things

    • @DrJohnnyStalker
      @DrJohnnyStalker 3 ปีที่แล้ว +1

      xpath is more powerfull

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

    thank for the best tutorial

  • @absoluteRandom69
    @absoluteRandom69 3 ปีที่แล้ว +1

    Hello John, Could you make a video on Scraping Tweets form Twitter?

  • @sounakchatterjee9059
    @sounakchatterjee9059 3 ปีที่แล้ว +1

    wonderful video
    just wanted to ask how to select a text from an element?

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

      With requests-html we just add “.full_text” at the end - you will also need “first = True” in there too

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

      @@JohnWatsonRooney Thanks John. Also wanted to know is there any forum (like discord) where I can post issues or share my code?
      Like I want to scrape the country name, cases, death etc. for eg. how to scrape the country name?
      covid19.who.int/table . Can you please assit?

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

    Please tell me the difference between select and find all method and which one to use when

  • @the1gofer
    @the1gofer 3 ปีที่แล้ว +1

    thanks

  • @technicallymind201
    @technicallymind201 3 ปีที่แล้ว +1

    Can you make one video on login in amazon by using requests

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

    That was amazing tutorial but I have a problem. I've got a class that has many values however a specificl value is changing in diffrent websites I mean that for example in page one I have my value in name = r.html.find('.sc-1bker4h-4.llfiOB')[0].text but in other I have that value in name = r.html.find('.sc-1bker4h-4.llfiOB')[5].text. Could you help me? Thanks in advance

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

    Can i use it with bs4 instead of requests_html

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

      Yes! I believe you need to use soup.select() instead of soup.find()

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

      @@JohnWatsonRooney Thanks bro...

  • @sidiqbrewstreet3548
    @sidiqbrewstreet3548 8 หลายเดือนก่อน

    Not working for scrape tiktok