How To Scrape (almost) ANY Website with Python

Sdílet
Vložit
  • čas přidán 21. 07. 2024
  • Grab IPRoyal Proxies and get 50% off with code JWR50 at iproyal.club/JWR50
    Using browser automation isn't generally my go to for scraping but sometimes it gives us an easy option for grabbing data. Scaling is an issue however, but combining playwright with scrapy gives us a good solid robust scraping method to add to our repertoire.
    JavaScript to Scroll to the bottom of the page:
    "setInterval(function () {var scrollingElement = (document.scrollingElement || document.body);scrollingElement.scrollTop = scrollingElement.scrollHeight;}, 200);",
    Scraper API www.scrapingbee.com/?fpr=jhnwr
    Patreon: / johnwatsonrooney
    Donations: www.paypal.com/donate/?hosted...
    Proxies: iproyal.club/JWR50
    Hosting: Digital Ocean: m.do.co/c/c7c90f161ff6
    Gear I use: www.amazon.co.uk/shop/johnwat...
    Disclaimer: These are affiliate links and as an Amazon Associate I earn from qualifying purchases
    timestamps
    00:00 Intro
    01:49 Playwright & Selectolax
    07:14 Playwright & Scrapy
  • Věda a technologie

Komentáře • 83

  • @JohnWatsonRooney
    @JohnWatsonRooney  Před rokem +5

    Grab IPRoyal Proxies and get 50% off with code JWR50 at iproyal.club/JWR50

    • @bakasenpaidesu
      @bakasenpaidesu Před rokem +5

      Can you make a video about how to use it properly?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +3

      yes will do

    • @bakasenpaidesu
      @bakasenpaidesu Před rokem +1

      @@JohnWatsonRooney thank you

    • @triott6497
      @triott6497 Před rokem

      I signed up for IPRoyal after watching your videos but couldn't get the static proxies to work. It returned timeout error. I tried changing the network settings but could not solve the problem. Do you have any idea what could cause such issues? Thanks.

  • @abdelrhmanabbas7228
    @abdelrhmanabbas7228 Před rokem +3

    You are a great tutor, and I suggest a video discussing and comparing all of these tools, why and when we could use them what is the best compo
    great work keep making tutorials

  • @tomermolnar6927
    @tomermolnar6927 Před rokem +1

    Brilliant! love your attitude, admire an out-of-the-box thinker! Keep up the good work buddy!

  • @stewart5136
    @stewart5136 Před rokem +2

    Another great video! Thanks for showing both methods. 💯

  • @edboss36
    @edboss36 Před rokem +7

    You are the webscrape master

  • @_manasikara
    @_manasikara Před rokem

    As a newbe... Does anyone have some experience with a PUP - a command line tool for processing HTML? Is there any way to import it to the Playwright project the same way as the HTMLParser? Thanks.

  • @vishalsugandh
    @vishalsugandh Před 5 měsíci

    Hey, how can we scrape PDFs that are embedded to be viewed by chrome pdf preview? I think they use javascript.

  • @DwellingsOfficial
    @DwellingsOfficial Před 4 měsíci

    It is playwirght faster and lighter than selenium?
    Because i have knowlede about Selenium but i dont know if its worth to start acquiring knowledge abour scrapy and playwrigh. ¿Should i start?
    Also, should i use playwright o splash? If i want to scrape data from dinamic and authenticated pages what should i use?
    I would love and appreciate any information or advice. Thank you! Sorry if my english is not perfect

  • @Kalter_int
    @Kalter_int Před rokem

    How to run a script from playwright in jupyter notebook?

  • @giftcp82
    @giftcp82 Před rokem +3

    can you please do a video on your neovim configuration

  • @successroutines
    @successroutines Před rokem +1

    Great video John

    • @successroutines
      @successroutines Před rokem

      I'm wondering if there is a way to use playwright with scrapy's shell? For me
      scrapy shell
      just seems to open the browser at the url and then block the scrapy shell from opening.

  • @StrifePulse
    @StrifePulse Před rokem

    Any way to get around PerimeterX?

  • @malwaredev33
    @malwaredev33 Před 3 měsíci

    Great video content about webscrape. Your doing amazing bro.

  • @greyngreyer5
    @greyngreyer5 Před rokem +1

    I'm literally just getting started with python and need a fast study done for my thesis so I decided to study word usage on reddit. Should go through with it? Idk if i need any special stuff :/ I don't even have python installed. Cheers

  • @podcaste4437
    @podcaste4437 Před rokem +3

    This is so timely for me @John, as I was literally building a scraper yesterday to scrape a website that used XHR. Top content! Additonally, would it be possible for you to share the java script "code" that was used in the PageMethod function?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +3

      Thanks for reminding me I've added it to the description now!

  • @TimCollins
    @TimCollins Před rokem +2

    Excellent tutorial! Thank you

  • @gabrielkcgamox
    @gabrielkcgamox Před rokem

    hiii, where is the github codes that you are using

  • @Drtsaga
    @Drtsaga Před 6 měsíci +1

    I watched the section between 4:30 and 5:00 (roughly) so many times.
    The off-by-one space there was extremely distracting as well as satisfying when fixed.
    Cheers

  • @comfortzonegames2131
    @comfortzonegames2131 Před rokem

    Next button is hidden for me. I am stuck

  • @StefanFlorescu-ur8uv
    @StefanFlorescu-ur8uv Před rokem +1

    Thanks for another great video!
    This method seems so easy and wanted to try it myself but unfortunately, it seems that scrapy-playwright doesn't work on windows. Some sort of Linux emulation (WSL) is required.
    Also thanks for the iproyal discount. I was looking for such a service and your discount comes just perfect, will use it after NYE party :)
    PS: Everyone, a Happy new year!

  • @devpala
    @devpala Před rokem +4

    Hey, the video is really really helpful. Thank you very much for it! You are the go to channel for me whenever I wish to research on any topic related to web-scraping. You're doing a great job man!
    Also, in the end of the video you said that this is not your preferred method for scrapping infinite scroll dynamic websites. So which one is your preferred method, which is also scalable?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +1

      Thanks I’m glad you’re enjoying the content! The way I mentioned is by reverse engineering the sites backend api and making requests to it - I have a few videos on my channel that explain the basics of this idea!

    • @devpala
      @devpala Před rokem +2

      @@JohnWatsonRooney Oh alright. Yeah I’ve gone through those videos of yours and they indeed made my task a lot easier. So thanks for that too! XD

  • @ishandandekar1808
    @ishandandekar1808 Před 5 měsíci +1

    Need you to make a nvim setup video because thats cool af

  • @ervankurniawan41
    @ervankurniawan41 Před rokem +1

    instead of playwright, can we use splash for any projects? which are recommended for web scraping?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem

      You absolutely can - it’s not as easy to setup and use well in my opinion but fits well into a specific use case. However I don’t think it’s been updated for a while and I’ve had some people tell me it hasn’t been working for them recently. Give it a go and if it works for you then great

  • @vinubalank
    @vinubalank Před rokem +1

    Hi John.. What options do you suggest if I have to save screenshot of webpage as jpeg or as html itself.. Is it possible to with Scrapy

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +1

      Yes! Where I have the pagemethods - you can add in another “screenshot” that will do it

    • @vinubalank
      @vinubalank Před rokem

      ​@@JohnWatsonRooney Thanks John

  • @jeroenvermunt3372
    @jeroenvermunt3372 Před rokem +1

    This is nice, but my problem with using playwright is that it the twisted reactor always leads to issues when I want to run my spiders using python scripts

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem

      you could try using Splash? It hasn't been updated in a few years but may still work. Or create your own scraping/render service separate and use that?

  • @shakhauathasan9555
    @shakhauathasan9555 Před rokem

    brother, i'm in a big problem. last 20 day's i'm trying to scrape one of site. but i failed all the time. I watched 100 of videos. but i failed. can you scrape a site for me. if possible plz reply to my comments. this is my final year project. you just scrape me some data. my final year defense in knocking my door. plz brother if possible reply my comments.

  • @Alam2k23
    @Alam2k23 Před rokem +2

    Thanks

  • @karthikb.s.k.4486
    @karthikb.s.k.4486 Před rokem +1

    What is the IDE and theme used for this?. Nice explanation

  • @doodelinux
    @doodelinux Před rokem +1

    Great video John, which Editor are you using ?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +1

      It’s neovim, with the basic ide config by chris@machine

    • @doodelinux
      @doodelinux Před rokem

      @@JohnWatsonRooney Thank you bud, I've been looking for an alternative to PyCharm and vscode for a while now

  • @casual_gamer1413
    @casual_gamer1413 Před rokem +2

    Which is the best for JavaScript rendered websites?
    Selenium or puppeteer or playwright?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem

      I use playwright mostly now

    • @casual_gamer1413
      @casual_gamer1413 Před rokem +1

      @@JohnWatsonRooney but I'm selenium expert, Should I use playwright instead of selenium or stick with the selenium according to your expertise?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem

      @@casual_gamer1413 selenium! as you say you already know it, they do the same thing for web scraping purposes

    • @casual_gamer1413
      @casual_gamer1413 Před rokem

      @@JohnWatsonRooney thank you❣️❤️

  • @yBlade05
    @yBlade05 Před rokem +1

    Off topic, but will you do a video on websockets?

  • @ramonmijangos1091
    @ramonmijangos1091 Před rokem

    John, Is it possible to scrapy an Android or iOS app

  • @MrTurt99
    @MrTurt99 Před rokem +1

    Is that turle neck from uniqlo? It looks 👌

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +3

      hah thanks - its Indicode brand.. but i got it from tk max

  • @vahsek7488
    @vahsek7488 Před rokem +2

    Hey how to scrape data from an Android application.

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +1

      not something I've done before, but i know that the app will have a backend server/api that it makes the requests too, you;'d need to find this and reverse engineer it. or it might be possible to emulate the app on a pc/through browser?

    • @jesseroeleveld5430
      @jesseroeleveld5430 Před rokem +1

      @@JohnWatsonRooney most apps have ssl pinning security so we can not intercept it, to bypass this we can use nox player and man in the middle proxy to intercept from nox

  • @AK-Star007
    @AK-Star007 Před rokem +1

    Do you think chatgpt will put many of us out of commision??

  • @manuelalejandrosalazargome1047

    yes

  • @ramzan1813
    @ramzan1813 Před rokem +1

    why you don't use selenium?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem +1

      I used to! It’s great.. I just spent more time with playwright and find it a bit easier to use

    • @ramzan1813
      @ramzan1813 Před rokem

      @@JohnWatsonRooney I use selenium it's powerful but some time it's some modules not working properly and thay makes me angry 😅 and I think I have move to new solutions but then I reminded myself that I have use proxies. But I don't like use of proxy I don't know why but I scares from using proxy.
      Is their any free proxies?

  • @kattamaran
    @kattamaran Před rokem +1

    I would really be interested on how to find api‘s 😊

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem

      i have a few videos on it on my channel! basically using the network tab in your browser to look for requests when pages are loaded

    • @kanwaradnan4849
      @kanwaradnan4849 Před rokem +1

      @@JohnWatsonRooney YEAH BUT IT DOES NOT WORK ALL THE TIMES.

    • @jesseroeleveld5430
      @jesseroeleveld5430 Před rokem

      @@kanwaradnan4849 for api usage it’s important to look at thenpayload that is sent. Is this a data form or a json payload? Also look good at the headers, this will fix 9/10 of your issues. Still doesn’t work? You probably forgot to fake some cookies :)

    • @kanwaradnan4849
      @kanwaradnan4849 Před rokem

      @@jesseroeleveld5430 yeah i found it buy watching video on this channel

    • @kanwaradnan4849
      @kanwaradnan4849 Před rokem

      @@jesseroeleveld5430 the reason I told the above statement is because I created a react app and it doesn't show my api using old tricks

  • @skshaheen7506
    @skshaheen7506 Před rokem

    If you're looking for a challenge, then try to scrape 9anime, It will be an interesting challenge. And also great content to watch. 🍿🍿

    • @techlogger
      @techlogger Před rokem +1

      My friend did it with just requests.

    • @skshaheen7506
      @skshaheen7506 Před rokem

      @@techlogger hmmm yes it's possible 🤔, but you have to find the API.

    • @techlogger
      @techlogger Před rokem +1

      @@skshaheen7506 yes. Not only api.. you have to solve heavy Java obfuscation too. It's more complicated than normal scraping

    • @skshaheen7506
      @skshaheen7506 Před rokem +1

      @@techlogger so after some digging with fiddler I have found the api and also able to get the video embedded url but couldn't get it to stream, since I have little JavaScript knowledge and unable to use the devtool (because they blocked it) this is as far as i can go for now, will try it later 😌.. and also as you mentioned this site use Obfuscated JavaScript.

    • @techlogger
      @techlogger Před rokem +1

      @@skshaheen7506 you can unblock devtools, stream links ( m3u8 links ) are mostly restricted.. you have to pass proper headers, payload or in some case a decryption key. And yes that website is heavily obfuscated. But it's doable.

  • @bakasenpaidesu
    @bakasenpaidesu Před rokem +2

    Can't say I'm first 😂

  • @heaton922
    @heaton922 Před rokem +1

    are you using lunar vim?

    • @JohnWatsonRooney
      @JohnWatsonRooney  Před rokem

      No but it’s the basic ide by the lunarvim author, it’s great