Latest / CyberCode Academy / Course 40 - Web Scraping with Python | Episode 38: Scraping Dynamic Premier League Stats and News with Selenium and BeautifulSoup
Transcript
- 0:00Speaker 1: So did you know that nearly half of all Internet
- 0:03Speaker 1: traffic isn't actually human.
- 0:05Speaker 2: Yeah, it's wild. It's a huge number, right.
- 0:07Speaker 1: Because we experience the web visually, you know, reading articles,
- 0:11Speaker 1: clicking pictures, scrolling through feeds. But underneath that visual layer,
- 0:15Speaker 1: there's just this massive, invisible economy of.
- 0:19Speaker 2: Bots exactly, just automated scripts that are constantly crawling and reading,
- 0:23Speaker 2: just extracting raw data from websites twenty four to seven.
- 0:27Speaker 1: And realizing that, I mean, it completely shifts how you
- 0:30Speaker 1: view the Internet because for a long time, if you
- 0:32Speaker 1: wanted to compile research or you know, gather data from
- 0:35Speaker 1: a website, you kind of had to act like a
- 0:37Speaker 1: robot yourself.
- 0:38Speaker 2: Oh yeah, the old copy and paste methage.
- 0:40Speaker 1: Yes, you'd sit at a monitor, spreadsheet open on a
- 0:43Speaker 1: one half of the screen, website on the other, and
- 0:45Speaker 1: you're just endlessly highlighting, copying, and pasting.
- 0:48Speaker 2: It is the absolute definition of soul crushing busy work.
- 0:51Speaker 2: I mean, nobody enjoys that.
- 0:53Speaker 1: Nobody. So today, in this deep dive, we are putting
- 0:56Speaker 1: an end to that manual copy and paste era. Mission
- 1:00Speaker 1: today is to demystify dynamic webscraping.
- 1:03Speaker 2: Which is such a powerful tool, it really is. We're
- 1:05Speaker 2: going to walk step by step through how to build
- 1:08Speaker 2: your own data gathering robot, because this is a crucial
- 1:12Speaker 2: skill for anyone and tech programming or data science who
- 1:15Speaker 2: really wants to turn a complex, interactive website into a
- 1:19Speaker 2: neat highly valuable data set.
- 1:21Speaker 1: And once you learn how to programmatically extract exactly what
- 1:24Speaker 1: you want from the web, the possibilities are just endless.
- 1:26Speaker 1: You transition from merely consuming information to actively harvesting it.
- 1:32Speaker 2: Which is a huge mental shift. And to ground this
- 1:36Speaker 2: in reality, you know, for you listening, we are going
- 1:38Speaker 2: to use a highly practical scenario today. We're going to
- 1:41Speaker 2: build a script that extracts the latest news headlines and
- 1:43Speaker 2: the lifetime career statistics for Wayne Rooney.
- 1:46Speaker 1: Nice a great test case.
- 1:48Speaker 2: Yeah, we're pulling this directly from the English Premier League website. Yeah,
- 1:51Speaker 2: and just for context, if you aren't a massive soccer fan,
- 1:54Speaker 2: Wayne Rooney is a famously talented English footballer. He has
- 1:58Speaker 2: this massive data rich career spanning over a decade at
- 2:02Speaker 2: clubs like Everton and Manchester United and even a stint
- 2:05Speaker 2: in the US with DC United. Right, and his profile
- 2:09Speaker 2: page on that Premier League site, it's the perfect test
- 2:11Speaker 2: case for this. Yeah, because it's not just some static,
- 2:14Speaker 2: boring documentary.
- 2:15Speaker 1: No, it's got a lot going on exactly.
- 2:16Speaker 2: It is a highly interactive, dynamic web page. It has tabs,
- 2:21Speaker 2: search bars, and content that loads dynamically as you click.
- 2:25Speaker 1: So to navigate all that complexity, we are relying on
- 2:28Speaker 1: a powerhouse trio of tools. We're using Python as our
- 2:31Speaker 1: foundational programming language, and then two specific packages, Selenium and
- 2:36Speaker 1: beautiful Soup.
- 2:37Speaker 2: The homely trinity of webscraping.
- 2:38Speaker 1: Basically, basically, yeah, So let's start with the first major hurdle.
- 2:42Speaker 1: Before we can extract a single piece of data, our
- 2:45Speaker 1: code needs to know how to actually navigate this interactive site, right.
- 2:49Speaker 2: Yeah, Because when you or I open a web browser,
- 2:51Speaker 2: we make countless intuitive decisions. We visually locate a search bar,
- 2:55Speaker 2: we move our mouse, we click.
- 2:57Speaker 1: We type, It's second nature to us, right.
- 3:00Speaker 2: Basic bython script. Well, it has no eyes and no hands.
- 3:03Speaker 2: It literally doesn't know how to interact with visual elements
- 3:06Speaker 2: on a screen.
- 3:07Speaker 1: So how do we fix that?
- 3:08Speaker 2: That's where Selenium comes in. Selenium is a tool that
- 3:10Speaker 2: bridges that gap. It allows Python to open a real
- 3:13Speaker 2: web browser in the background and simulate those human physical interactions.
- 3:18Speaker 1: Okay, I love that. I always think of Selenium as
- 3:21Speaker 1: like a programmable self driving car for your web browser.
- 3:24Speaker 2: That's a perfect analogy, actually, right.
- 3:26Speaker 1: You give it the directions and it literally turns the
- 3:28Speaker 1: steering wheel. So, set by step, we code our script
- 3:31Speaker 1: to navigate to the Premier League homepage. Then we use
- 3:34Speaker 1: a specific command. It's called find element by link text.
- 3:38Speaker 2: YEP, very common commands.
- 3:39Speaker 1: So we are instructing our robot to scan the screen
- 3:42Speaker 1: for the exact text that says players and then click
- 3:45Speaker 1: that link.
- 3:46Speaker 2: And from there, the script locates the search box, types
- 3:49Speaker 2: in the name Wayne Rooney, hits the return key, and
- 3:52Speaker 2: then clicks on his image when it pops up in
- 3:54Speaker 2: the search.
- 3:55Speaker 1: Results, just exactly like a human would.
- 3:57Speaker 2: Exactly, and that lands us on his actual profile page.
- 4:00Speaker 2: But to make this specific sequence actually work without crashing,
- 4:05Speaker 2: we have to introduce a fundamental technical concept called weights.
- 4:08Speaker 1: Okay, wait, I need to jump in on this because
- 4:10Speaker 1: if I'm running the script on a modern machine, my
- 4:13Speaker 1: Python code executes in milliseconds.
- 4:16Speaker 2: Right easily, super fast.
- 4:18Speaker 1: So why am I manually coding pauses into my script?
- 4:22Speaker 1: Shouldn't the whole advantage of an automated bot be that
- 4:24Speaker 1: it just blasts through these steps at maximum computer speed.
- 4:29Speaker 2: Well, if the Internet ran at the speed of your
- 4:31Speaker 2: computer's processor, absolutely, but it doesn't. See your code runs
- 4:36Speaker 2: locally at lightning speed, while the website you're interacting with
- 4:40Speaker 2: is loading at network speed, and dynamic websites load different
- 4:43Speaker 2: elements at totally varying speeds depending on server load, your
- 4:47Speaker 2: internet connection, or just the file size of the images.
- 4:50Speaker 1: So if my script fires off a command to like
- 4:52Speaker 1: click the rain Rooney image a millisecond after hitting search.
- 4:56Speaker 2: The browser hasn't even finished loading the search results yet, right, Yeah,
- 5:00Speaker 2: the image literally doesn't exist in the browser's reality at
- 5:03Speaker 2: that exact moment. So your script tries to click a
- 5:06Speaker 2: ghost button, throws an error, and the entire program just crashes.
- 5:09Speaker 1: That sounds incredibly frustrating.
- 5:11Speaker 2: It is so to prevent that, you have to artificially
- 5:15Speaker 2: throttle your code to match the slower reality of the
- 5:18Speaker 2: web page.
- 5:19Speaker 1: Which brings us to the two distinct tools we use
- 5:22Speaker 1: to manage this timing, explicit weights and implicit weights, and
- 5:26Speaker 1: they serve very different purposes, very different Yeah. So when
- 5:28Speaker 1: we first click the player's section, there is a small
- 5:31Speaker 1: delay before the search bar even appears. To handle this,
- 5:34Speaker 1: we code an explicit weight, right.
- 5:36Speaker 2: An explicit weight is a highly targeted pause. You are
- 5:40Speaker 2: instructing the webdriver to halt all execution until a very
- 5:44Speaker 2: specific condition is satisfied.
- 5:45Speaker 1: Like waiting for a green light.
- 5:47Speaker 2: Exactly. You are basically saying, do not execute the next
- 5:50Speaker 2: line of code until the HTML element for the search
- 5:52Speaker 2: bar is visibly present on the screen. And it doesn't
- 5:55Speaker 2: matter if it takes one second or ten seconds. The
- 5:58Speaker 2: clock is irrelevant. The condition is everything.
- 6:01Speaker 1: It's like waiting for a friend at a coffee shop.
- 6:03Speaker 1: You are just going to wait ten minutes and then
- 6:05Speaker 1: order your coffee, regardless of whether they show up or not.
- 6:07Speaker 1: You know, you are specifically waiting for the condition of
- 6:10Speaker 1: them walking through the door.
- 6:11Speaker 2: That's a great way to think about it. Now, contrast
- 6:13Speaker 2: that with an implicit weight, which is what we use
- 6:16Speaker 2: after we type his name and hit return.
- 6:18Speaker 1: Right, So how is that different?
- 6:19Speaker 2: An implicit weight is more of a blanket safety net
- 6:22Speaker 2: that you apply to the entire webdriver. Okay, you are
- 6:25Speaker 2: saying a universal rule that basically says, hey, if you
- 6:29Speaker 2: ever try to find an element and it's not there,
- 6:31Speaker 2: immediately just wait for a maximum of say five seconds,
- 6:36Speaker 2: before giving up and throwing an error.
- 6:38Speaker 1: So it's not looking for one specific thing exactly.
- 6:41Speaker 2: It isn't waiting for a specific condition. It simply builds
- 6:44Speaker 2: a universal buffer of patients into your whole strip.
- 6:47Speaker 1: Got it. So, with our explicit and implicit weights successfully coded,
- 6:52Speaker 1: Selenium safely navigates the search bar, types the name, and
- 6:55Speaker 1: clicks the picture, we are now officially parked on Wayne
- 6:58Speaker 1: Rooney's profile page.
- 7:00Speaker 2: Mission accomplished for the driver.
- 7:01Speaker 1: Exactly. At this point, we instruct Selenium to grab all
- 7:06Speaker 1: the raw information that makes up that web page, which
- 7:08Speaker 1: is called the pave source, and we save it into
- 7:10Speaker 1: a variable in our code. But and this is a
- 7:13Speaker 1: big butt. If you actually print that variable out to
- 7:16Speaker 1: your screen to look at it, it is a massive,
- 7:18Speaker 1: incredibly intimidating wall of raw HTML code.
- 7:21Speaker 2: It is practically unreadable for a human. I mean, we
- 7:24Speaker 2: are talking about thousands of lines of nested brackets, random
- 7:28Speaker 2: tags in line styling, and just.
- 7:30Speaker 1: Structural noise, absolute chaos.
- 7:32Speaker 2: Yeah, and the actual data we want is very deep
- 7:35Speaker 2: inside that chaos.
- 7:36Speaker 1: So this limitation pushes us into the next phase of
- 7:39Speaker 1: our process. We need a way to actually read this mess.
- 7:42Speaker 1: So we import a new package, our third tool, called
- 7:44Speaker 1: beautiful Soup.
- 7:45Speaker 2: Such a great name for a library, it really is.
- 7:47Speaker 1: We feed beautiful Soup that massive wall of page source
- 7:50Speaker 1: code and we parse it using an XML parser. But
- 7:54Speaker 1: let me ask the obvious question here, because I know
- 7:56Speaker 1: you're probably wondering this too. If Selenium is already running
- 7:59Speaker 1: the page and we just use Selenium to successfully find
- 8:01Speaker 1: a search bar and click a button, why can't Selenium
- 8:04Speaker 1: just read the text?
- 8:04Speaker 2: We want fair question.
- 8:06Speaker 1: Right, Like why complicate the script with a whole new tool.
- 8:10Speaker 2: It really comes down to system resources and processing efficiency.
- 8:14Speaker 2: Think of Selenium as a heavy duty forklift.
- 8:17Speaker 1: Okay, a forklift.
- 8:18Speaker 2: Yeah, it is incredibly powerful. It can move heavy paletts,
- 8:22Speaker 2: navigate warehouse aisles, and interact with the physical space of
- 8:25Speaker 2: the web page. But because it is actively running a
- 8:29Speaker 2: full web browser instance in the background, it is incredibly
- 8:32Speaker 2: resource intensive. It's super clunky when it comes to just
- 8:36Speaker 2: speed reading static text.
- 8:37Speaker 1: Yeah, I guess you wouldn't use a forklift to organize
- 8:40Speaker 1: a filing cabinet, exactly.
- 8:42Speaker 2: Beautiful Soup, on the other hand, is the auditor who
- 8:44Speaker 2: steps in with a clipboard. It doesn't open a browser
- 8:47Speaker 2: doesn't click buttons. It just takes that massive wall of
- 8:50Speaker 2: raw static code and purces it lightning fast.
- 8:53Speaker 1: And we specifically use an XML parser for this. Let's
- 8:56Speaker 1: break down what a parser actually does, and you know
- 8:58Speaker 1: why we use an XML parser on an HTML web page.
- 9:01Speaker 2: Sure? So, a parser basically takes a flat, chaotic string
- 9:04Speaker 2: of text and analyzes its underlying structure to build a searchable,
- 9:08Speaker 2: hierarchical tree.
- 9:09Speaker 1: So it organizes it exactly.
- 9:11Speaker 2: Think of it like turning a massive block of unformatted
- 9:13Speaker 2: text into a detailed family tree where every paragraph or
- 9:17Speaker 2: image is a specific labeled branch.
- 9:19Speaker 1: Okay, so why XML then?
- 9:21Speaker 2: Well, HTML code, by its very nature is often very
- 9:25Speaker 2: messy in forgiving, Yeah, web developers sometimes leave tags open,
- 9:29Speaker 2: or they write sloppy code, and web browsers are designed
- 9:31Speaker 2: to just silently fix it and display the page anyway.
- 9:34Speaker 1: Humans are messy, browsers compensate.
- 9:36Speaker 2: Right, But a bot can't deal with sloppy code. It
- 9:39Speaker 2: needs rigorous, predictable logic, which is.
- 9:41Speaker 1: Why we feed the HTML through an XML parser.
- 9:44Speaker 2: Bingo XML is a much stricter, much more disciplined markup language.
- 9:49Speaker 2: By using an XML parser on HTML, beautiful soup forces
- 9:52Speaker 2: that messy web code into a highly structured, perfectly nested,
- 9:56Speaker 2: easily navigable tree of data.
- 9:58Speaker 1: Okay, so now that we have this beautiful, fully organized
- 10:00Speaker 1: tree of data thanks to our auditor, we have to
- 10:03Speaker 1: actually locate the specific nuggets of information we are looking for.
- 10:06Speaker 1: That's on part Yeah, let's start with extracting the latest
- 10:09Speaker 1: Wayne Rooney news headlines.
- 10:11Speaker 2: So this requires a little bit of preliminary detective work.
- 10:14Speaker 2: If you open the Premier League site yourself and use
- 10:17Speaker 2: your browser's inspect tool, you know, to look at the
- 10:19Speaker 2: underlying code of the news section, you will see a
- 10:22Speaker 2: very deliberate structural pattern.
- 10:24Speaker 1: Because developers are organized exactly.
- 10:26Speaker 2: Web developers use specific HTML tags to categorize content so
- 10:31Speaker 2: they can style it consistently across the whole site.
- 10:34Speaker 1: Right, And in this specific case, we see that all
- 10:36Speaker 1: the news headlines are wrapped inside a specific tag, which
- 10:39Speaker 1: is a span tag. And more importantly, they all share
- 10:42Speaker 1: a specific class name called title.
- 10:44Speaker 2: Yes, the developers assign the class name title so they
- 10:47Speaker 2: can just tell the website, hey, make everything in this
- 10:49Speaker 2: class bold and eighteen point font. They do it for
- 10:52Speaker 2: visual styling, but we exploit that underlying architecture as a
- 10:56Speaker 2: data label.
- 10:57Speaker 1: It's like finding the hidden map. So in our pipe
- 11:00Speaker 1: on script we use a beautiful soup command called findal.
- 11:03Speaker 1: We simply instruct beautiful soup to scan the entire parse
- 11:06Speaker 1: tree and isolate only the elements that are under a
- 11:09Speaker 1: span tag and belong to the title class.
- 11:11Speaker 2: And it's so fast. The parser instantly filters out the
- 11:15Speaker 2: millions of characters of junk we don't care about, leaving
- 11:18Speaker 2: us with just the specific lines containing the headlines.
- 11:21Speaker 1: It's like X ray glasses for code. Then we just
- 11:23Speaker 1: run a quick extraction command to strip away the HTML
- 11:26Speaker 1: formatting brackets, leaving only the pure text, and boom, Just
- 11:30Speaker 1: like that, you have a clean list of the latest
- 11:33Speaker 1: headlines saved directly in your script.
- 11:35Speaker 2: It's incredibly satisfying when it.
- 11:37Speaker 1: Works, it really is. But extracting the headlines was pretty
- 11:40Speaker 1: straightforward because of that neat title class. When we try
- 11:43Speaker 1: to get Wayne Rooney's career stats, we hit a bit
- 11:46Speaker 1: of a roadblock.
- 11:47Speaker 2: Yeah, because the stats aren't on this main overview page.
- 11:50Speaker 2: We have to navigate to a completely different tab on
- 11:52Speaker 2: his profile.
- 11:53Speaker 1: Right, So the auditor has to step aside and the
- 11:55Speaker 1: driver gets back in the forklift. We switch back to
- 11:58Speaker 1: Selenium to click the stats.
- 12:00Speaker 2: But here's the real challenge. When we inspect the code
- 12:03Speaker 2: for the stats button, it doesn't have a convenient class
- 12:06Speaker 2: name that we can target.
- 12:07Speaker 1: Oh no, So how do we tell Selenium what to
- 12:10Speaker 1: click if there is no clear label?
- 12:12Speaker 2: We rely on a much more powerful targeting method called an.
- 12:15Speaker 1: XPath an XPath okay, explain that.
- 12:18Speaker 2: Well, if a class name is like telling someone to
- 12:21Speaker 2: look for a book in the mystery section of a library,
- 12:24Speaker 2: an XPath is giving them the exact floor, aisle, shelf number,
- 12:28Speaker 2: and physical position of that specific book.
- 12:30Speaker 1: Wow. Okay, that's precise.
- 12:32Speaker 2: Very And an XPath is the literal directory path of
- 12:36Speaker 2: an element within the web page's underlying code structure. It
- 12:39Speaker 2: looks kind of like a file path on your computer,
- 12:42Speaker 2: like slash div slash button. You know.
- 12:44Speaker 1: Got it. So we feed that highly specific X path
- 12:48Speaker 1: coordinate to Selenium and it clicks the button perfectly. The
- 12:51Speaker 1: browser navigates to the stats tab. We grab the new
- 12:54Speaker 1: page source, hand it back to beautiful Soup, parse it
- 12:57Speaker 1: into a new tree, and we go hunting for the
- 12:59Speaker 1: numbers again.
- 13:00Speaker 2: In inspecting the stats page, we find that the data
- 13:02Speaker 2: we want is housed within a broad container class appropriately
- 13:06Speaker 2: named all stat.
- 13:07Speaker 1: Container nice when they name things clear definitely.
- 13:10Speaker 2: So we use our trustee final command to isolate it.
- 13:12Speaker 1: But looking at the elements inside that container reveals something
- 13:15Speaker 1: really fascinating about how websites separate visual texts from structural data.
- 13:20Speaker 2: Yes, if you look closely, you'll notice the titles of
- 13:23Speaker 2: the statistics. So the labels like goals, assists or appearances,
- 13:28Speaker 2: those are actually stored inside HTML attributes called data stat attributes. Yeah,
- 13:34Speaker 2: attributes are basically hidden pieces of metadata tucked inside the
- 13:38Speaker 2: HTML code. You don't see them on the screen.
- 13:40Speaker 1: Oh interesting.
- 13:41Speaker 2: Meanwhile, the actual numbers, like the two to zerweight goals,
- 13:44Speaker 2: the one er three assists, those are stored as standard
- 13:47Speaker 2: visual text that the user actually reads.
- 13:50Speaker 1: So the developer put the label in the back end
- 13:52Speaker 1: metadata for their own organizational purposes and then left the
- 13:56Speaker 1: number as plain text for the fan looking at the screen.
- 13:59Speaker 2: Exactly, So, our extraction code just tackles both. We pull
- 14:02Speaker 2: the titles out of the hidden data stat attributes, and
- 14:05Speaker 2: we extract the numbers from the visual text.
- 14:07Speaker 1: And then we pair them up programmatically.
- 14:08Speaker 2: Yep, and suddenly we have pristine, complete career statistics extracted
- 14:14Speaker 2: entirely automatically, no highlighting, no manual data entry.
- 14:17Speaker 1: That is just so cool. Getting the script to successfully
- 14:21Speaker 1: pull WAYN. Rooney's data is an incredible feeling. But I mean,
- 14:25Speaker 1: scriping a single page is really just a parlor trick,
- 14:27Speaker 1: isn't it. The true transformative power of this process lies
- 14:31Speaker 1: in scalability, oh one hundred percent.
- 14:34Speaker 2: If you analyze the script we just built, you will
- 14:36Speaker 2: realize it contains very little Wayne Runey specific logic. What
- 14:40Speaker 2: do you mean, well, finding a search bar, waiting for
- 14:43Speaker 2: an elemental load, parsing HTML, hunting for the title class
- 14:47Speaker 2: or the all stack container. That underlying architecture is identical
- 14:51Speaker 2: for every single player in the Premier League database.
- 14:54Speaker 1: Ah, so with a few minor variable changes, this exact
- 14:59Speaker 1: script becomes completely player agnostic exactly.
- 15:02Speaker 2: Instead of hard coding a single name, you could feed
- 15:04Speaker 2: the script a text file containing the names of say
- 15:07Speaker 2: five hundred different players. Yea, you execute the code, step
- 15:09Speaker 2: away from your computer, go get a coffee, and let
- 15:12Speaker 2: your bots systematically crawl the site. It's effectively doing the
- 15:14Speaker 2: work of a dozen data entry clirks in a matter
- 15:17Speaker 2: of minutes.
- 15:17Speaker 1: That is insane leverage, but generating that massive data set
- 15:22Speaker 1: begs the ultimate question, what do you actually do with
- 15:26Speaker 1: thousands of rows of scraped stats and headlines once you
- 15:29Speaker 1: have them?
- 15:30Speaker 2: Right? Because web scraping is really just the top of
- 15:33Speaker 2: the funnel. It is the raw fuel that powers advanced
- 15:36Speaker 2: data science and machine learning.
- 15:38Speaker 1: So to process that sheer volume of data, we would
- 15:41Speaker 1: load our scraped results into a tool like a Panda's
- 15:44Speaker 1: data frame and Python. And if you are unfamiliar with that,
- 15:47Speaker 1: a data frame is basically a highly powered programmable spreadsheet.
- 15:52Speaker 2: Yeah, and traditional spreadsheets really struggle when you start throwing
- 15:55Speaker 2: millions of data points at them. They just lock up definitely.
- 15:57Speaker 1: Excel just freezes, right.
- 16:00Speaker 2: Panda's data frames utilize a concept called vectorization, which is
- 16:04Speaker 2: vectorization basically allows you to apply complex mathematical operations to
- 16:08Speaker 2: an entire column of data simultaneously, almost instantly. You don't
- 16:12Speaker 2: have to write slow, repetitive loops going row bi row.
- 16:15Speaker 1: So once your scrape data is loaded into pandas, the
- 16:17Speaker 1: analytical possibilities just absolutely explode.
- 16:20Speaker 2: They do. Let's take those news headlines we scrape, for example.
- 16:23Speaker 2: Unstructured text is notoriously hard to analyze, but you could
- 16:28Speaker 2: run an actual language processing script or NLP over those
- 16:32Speaker 2: headlines to perform sentiment analysis.
- 16:35Speaker 1: Oh that's fascinating. How does that work?
- 16:37Speaker 2: Well, the innerpiece script evaluates the vocabulary of the article,
- 16:41Speaker 2: looking for positive or negative words, and as finds it
- 16:44Speaker 2: a mathematical positivity or negativity score.
- 16:46Speaker 1: So suddenly you have a hard numerical metric for how
- 16:50Speaker 1: the media is talking about a player this week. It's
- 16:52Speaker 1: not just a vibe, it's a data point exactly.
- 16:55Speaker 2: And then you take that sentiment score, you merge it
- 16:57Speaker 2: with the physical career statistics, we extract it from the
- 16:59Speaker 2: d data stat attributes, and you feed that massive multidimensional
- 17:03Speaker 2: data set into a machine learning algorithm.
- 17:06Speaker 1: Mind blowing.
- 17:07Speaker 2: You are no longer just looking at historical records. You
- 17:09Speaker 2: are using the raw materials you scraped to build predictive
- 17:12Speaker 2: models about how a player might perform in an upcoming match.
- 17:16Speaker 1: So the scraping bot just gathers the wood and the stone.
- 17:19Speaker 1: But what kind of analytical house you build with those
- 17:21Speaker 1: materials is entirely up to your own technical imagination.
- 17:25Speaker 2: It's incredibly empowering.
- 17:26Speaker 1: It really is okay to lock in some of these
- 17:28Speaker 1: foundational concepts. For you listening, I want to pose a
- 17:31Speaker 1: quick mental exercise A little review question, Oh I like
- 17:34Speaker 1: this put them on the spot exactly. So think back
- 17:38Speaker 1: to our breakdown of web driver weights. Imagine you are
- 17:41Speaker 1: building a bot to scrape a totally different website, and
- 17:45Speaker 1: this particular site is notorious because a pop up ad
- 17:48Speaker 1: occasionally appears right in the middle of the screen, completely
- 17:51Speaker 1: blocking the data.
- 17:52Speaker 2: You want classic Internet annoyance right now.
- 17:55Speaker 1: The catch is the timing of the pop up is
- 17:58Speaker 1: wildly unpredictable. Sometimes it appears instantly, other times it takes
- 18:02Speaker 1: like eight seconds to trigger. So if you had to
- 18:05Speaker 1: write the code to pause your script and handle that
- 18:08Speaker 1: unpredictable pop up, would you implement an explicit weight or
- 18:12Speaker 1: an implicit weight? Take a second to mentally lock in
- 18:15Speaker 1: your answer based on how we define them earlier.
- 18:18Speaker 2: It require is really analyzing the specific behavior of the obstacle,
- 18:21Speaker 2: doesn't it?
- 18:22Speaker 1: Yes, it does. Okay, If you guessed explicit weight, you
- 18:25Speaker 1: have a really solid grasp on the logic because the
- 18:27Speaker 1: pop up timing is completely erratic. An implicit weight, which remember,
- 18:32Speaker 1: just sets a universal time limit, might fail if the
- 18:35Speaker 1: ad takes too long to load. You need an explicit
- 18:38Speaker 1: weight to instruct your driver halt all execution until the
- 18:42Speaker 1: specific condition of that AD appearing is satisfied, which then
- 18:45Speaker 1: allows your code to click the X and.
- 18:47Speaker 2: Close it exactly matching the specific tool to the behavioral
- 18:51Speaker 2: quirks of the dynamic web page is the absolute essence
- 18:54Speaker 2: of building a robust scraper. If you don't do that,
- 18:58Speaker 2: your bot will just break all the time, Which.
- 19:00Speaker 1: Leaves us with a broader, somewhat provocative reality to consider
- 19:04Speaker 1: as we wrap up. The tools we just discussed are
- 19:06Speaker 1: incredibly powerful for extracting information, but web developers are highly
- 19:10Speaker 1: aware of that.
- 19:11Speaker 2: Oh, they definitely are.
- 19:12Speaker 1: As websites become increasingly dynamic, the developers building them are
- 19:15Speaker 1: constantly deploying new defenses to block automated scrapers. They're randomizing
- 19:20Speaker 1: class names daily, they're obfuscating EACHTML structures, or they're deploying
- 19:24Speaker 1: complex bot detection algorithms.
- 19:26Speaker 2: It is escalated into a massive, invisible cat and mouse
- 19:29Speaker 2: game playing out across the Internet every single second of
- 19:32Speaker 2: every day.
- 19:33Speaker 1: It really has, And on the flip side, artificial intelligence
- 19:37Speaker 1: is making scraping bots more adaptive, allowing them to dynamically
- 19:40Speaker 1: read and bypass those defenses on the fly.
- 19:43Speaker 2: The bots are getting smarter.
- 19:44Speaker 1: Too exactly, So, how will this escalating arms race between
- 19:48Speaker 1: web developers trying to hide and protect data and data
- 19:51Speaker 1: scientists building smarter tools to extract it reshape the fundamental
- 19:56Speaker 1: architecture of the open Internet. Will public data remain truly
- 20:00Speaker 1: public or will it retreat behind ever higher walls of
- 20:03Speaker 1: dynamic defensive code.
- 20:05Speaker 2: It is a fascinating tension, and I think it's going
- 20:07Speaker 2: to define the next decade of web infrastructure.
- 20:09Speaker 1: I completely agree, so I highly encourage you to take
- 20:12Speaker 1: the concepts we discussed today, explore your own ideas for
- 20:15Speaker 1: data sets, and just see what you can uncover. The
- 20:18Speaker 1: Internet is full of raw materials waiting to be utilized. Absolutely,
- 20:21Speaker 1: Just remember, the next time you find yourself manually copying
- 20:24Speaker 1: and pasting endless rows of data, stop. You possess the
- 20:27Speaker 1: tools to build a robot that does the heavy lifting
- 20:30Speaker 1: for you. So open up your terminal and start building