Web scraping: Claude Code for Economists with Paul Goldsmith-Pinkham | Markus Academy | Ep. 162-3 — Transcript
Full transcript
- 0:08Welcome back everybody
- 0:11to the mini video series on how to use
- 0:13Cloud Code for applied economists with
- 0:16Paul Smith Bingham. Hi Paul.
- 0:18Hi Marcus, how you doing?
- 0:21Now we have the third video. First we
- 0:24did installation and terminal setup for
- 0:26Cloud Code and Co-work as well.
- 0:29And then we talked about data analysis
- 0:30with a simple example and today Paul
- 0:33will show show us how to scrap
- 0:36data from the web.
- 0:37And we're looking forward to Paul's
- 0:40presentation. [snorts]
- 0:42Great. So today we're really going to be
- 0:44kind of
- 0:45deep in the the woods of doing stuff
- 0:48like
- 0:49coding and kind of right at the command
- 0:51line relative to this. So previously we
- 0:53had done some work
- 0:55kind of
- 0:57really using uh you know, Co-work and
- 0:59different things we were talking about
- 1:01the the different different things.
- 1:03Um
- 1:05today we're going to really be focused
- 1:07on um
- 1:10kind of doing a real data collection
- 1:11exercise kind of right at the command
- 1:13line just so you can kind of see how
- 1:14powerful using Cloud Code is. These are
- 1:15things I think that would be doable in
- 1:17Cloud Co-work but for today we're going
- 1:18to focus really on Cloud um Co-work.
- 1:21So
- 1:22um
- 1:24before we were kind of downloading data
- 1:26directly from a government API. So this
- 1:29is kind of one of the benefits with
- 1:30this, right? Is that it's the data is
- 1:32kind of very well structured. We were
- 1:33kind of downloading from an API or from
- 1:35tables that were already made from
- 1:37something that it's meant to be used.
- 1:39But a lot of stuff that we're going to
- 1:40do, the data isn't really that
- 1:41structured at all. So it's you know,
- 1:43we're scraping something from the web or
- 1:45we're given data that's kind of very
- 1:46messy and we're going to do a lot of
- 1:48work to turn it into something that is
- 1:49structured. So what we're going to do
- 1:51today is we're going to use something
- 1:53from the SEC the the Securities Exchange
- 1:55Commission's uh website which is called
- 1:57Edgar. Now, this is still a very
- 1:59structured data set, but it's really
- 2:00used for regulatory um filings as
- 2:03different companies file things. And
- 2:06we're going to take what are called
- 2:0710-Ks which are annual filings made by
- 2:09companies.
- 2:10Where we're going to we're going to pull
- 2:12stuff out. We're going to build a
- 2:13database and then we're going to
- 2:14basically do some basic analysis here.
- 2:16And we're going to do it all with cloud
- 2:18code. So, the example that I want to I
- 2:20want to do is is thinking about um
- 2:22tariffs.
- 2:23So, this is just you know, is I
- 2:25something I picked. We could pick lots
- 2:27of stories, but I think this would be a
- 2:28fun one. So, there in 10-Ks, there is
- 2:31something called item 1A which are these
- 2:33risk factors which is basically you
- 2:35describe material risks that face your
- 2:37company. So, when you have new risks,
- 2:39you have to talk about it. So, there's
- 2:41no quantity per se described in it. But,
- 2:43one thing that's interesting to measure
- 2:45is sort of how much these tariff risks
- 2:47change and came up and how often is this
- 2:49being described as a material risk over
- 2:51time for these folks.
- 2:53Um you know, this is a lot of related to
- 2:55a lot of work about uh this is the work
- 2:57by Baker, Bloom, and Davis thinking
- 2:59about policy uncertainty and macro. And
- 3:01it's just risk factors generally is is
- 3:03really interesting kind of
- 3:05if you're interested in this type of
- 3:06problem, there's no reason to focus per
- 3:08se on tariffs, but pulling this data can
- 3:09be kind of a pain. I'm going to show you
- 3:11it's really
- 3:12kind of a straightforward problem. So,
- 3:15we're going to do a number of things,
- 3:17but it's all going to kind of be we're
- 3:18not going to have to do too much. You
- 3:20mainly Marcus and I will be sitting here
- 3:21watching what's going on and talking
- 3:23about it. We're going to scrape 10-K
- 3:25filings from Edgar. We're going to
- 3:26extract the information from item 1A.
- 3:28We're going to put this into a database
- 3:30and then we're going to query that
- 3:32database to talk about various trends
- 3:34that are used in that. And maybe we'll
- 3:35make a picture that kind of looks nice
- 3:37um to describe this.
- 3:39So, I'm going to just show you what this
- 3:41looks like and then I'm about to move
- 3:43over to the command line in a second,
- 3:44but I'm going to kind of really give a
- 3:45structured prompt um for this just to
- 3:48make life easy. Um
- 3:51I'm going to ask I'm going to say I want
- 3:52to build a database a data set of 10K
- 3:55risk factors
- 3:56um from SEC SEC Edgar to study how
- 3:59tariff related risk disclosure change
- 4:01from this time period. We could change
- 4:02that if you wanted. Here's what I need
- 4:04to know or here's what I want to know
- 4:06from Edgar. Every company here or here's
- 4:09what I know about it, excuse me. Every
- 4:10company has a CIK, which is just means
- 4:12that there's a If you have a company,
- 4:15you have a number in Edgar that's
- 4:16associated with you.
- 4:18Here is where the API is.
- 4:21So
- 4:22for this one, I'm going to give Claude a
- 4:24little more context up front than usual.
- 4:26So, you know, I'm going to actually tell
- 4:29it a little more explicitly the things
- 4:30that I know. I'm not going to be so
- 4:31quite as vague as I was in the last
- 4:33prompt, mainly to make life easier for
- 4:34it. If you remember from the first
- 4:36video, I talked about is kind of the the
- 4:38how well it does as a function of how
- 4:40clear and precise you are. So, the more
- 4:43precise I am, the less it can have to
- 4:44search randomly for things. I'm going to
- 4:46say, "Look, I want to build a data set
- 4:47of 10K risk factors
- 4:50to study how tariff related risk
- 4:51disclosure change. Here's what I know.
- 4:54So, I know how it's structured. You have
- 4:56to have a CIK. You need Here's the um
- 4:59Edgar filing API and here's how you
- 5:01should rate limit it. And you need to
- 5:02use something called the user agent
- 5:03header, which is a way, if you remember
- 5:05from the last video, that this is to
- 5:07keep it from basically so it can clear
- 5:10these websites.
- 5:11And I want 10Ks What's the rate limit?
- 5:14Sorry.
- 5:15Oh, the rate limit is so that it doesn't
- 5:16just try and get too many files from
- 5:18this. So, I'm saying I see. You can only
- 5:20download, you know, 10 every second
- 5:22here. So, it's it's to keep you from
- 5:25spamming the server and getting blocked.
- 5:27And most of the time
- 5:29uh Claude would know beforehand, but
- 5:31this is
- 5:32This is roughly the rate that you can
- 5:33>> And the user agent, that's
- 5:35Yes, that's just a way to um to tell
- 5:37This is a way to tell the Python script
- 5:39that it writes to pretend they basically
- 5:42have to have a user agent associated
- 5:43with it, which is going to be my name
- 5:44and my email address. Okay. Um you're
- 5:47going to say, I want and I'm going to do
- 5:48it for 30 firms in different things. I'm
- 5:51going to just give it some examples.
- 5:52Obviously, if we're doing this for a
- 5:53research project, we'd say do it for
- 5:55every, you know, publicly listed stock,
- 5:56you know, all 500 and maybe I give it a
- 5:58list of names. But for here, I'm just
- 6:00going to let Claude make some decisions.
- 6:02Okay. So, I'm going to do this now. I'm
- 6:03going to take this over. So, I'm going
- 6:04to pause for 1 second as I move over and
- 6:06do this on the command line.
- 6:08Great. So, here we are at the command
- 6:10line, Marcus. So, what we're going to do
- 6:11is I'm going to make a a folder that
- 6:13this is inside of the one of the things
- 6:15that I've been doing. It's I'm just
- 6:16called a
- 6:17I'm just going to make a folder that
- 6:18we'll go in. We're going to start a new
- 6:20fresh Claude
- 6:22um session.
- 6:24And
- 6:25here, I'm going to tell it to basically
- 6:28create um I'm going to give it the
- 6:30prompt that we just talked about. So,
- 6:31we're going to start the project. So,
- 6:32I'm going to put it in. It's going to
- 6:34have this pasted text and I'm going to
- 6:36say I want to build a data set, blah
- 6:37blah blah. It's everything we just
- 6:38talked about. Mhm. So, it's going to
- 6:39start thinking and it's going to say,
- 6:40"Okay, I'm going to enter plan mode."
- 6:43So, now it's saying, "Okay, I need to
- 6:44make a plan on how to do this." So, let
- 6:46me think about how to do this.
- 6:48"Okay, it's going to look here."
- 6:51Um
- 6:52it's thinking. And so, one thing you can
- 6:54do is you can look
- 6:57and it's saying it it ran a command. It
- 6:59said this is called LS, which means it
- 7:01looks inside. It says, "Hey, this is a
- 7:02brand new folder. There's nothing in
- 7:04here." Yeah. So, it's thinking. So, you
- 7:06remember how we talked about how there's
- 7:07a context window where it does lots of
- 7:08stuff. So, now it says, "Wants to build
- 7:10a thing that does this. This is a
- 7:11project a substantial project that
- 7:13involves all these things. It's a
- 7:14non-trivial implementation. Let me enter
- 7:16plan mode to design the approach before
- 7:18doing this."
- 7:20Now, it's saying, "Okay, let me look at
- 7:22this and research the Edgar API before
- 7:24designing it." I'm going to say, "Yes,
- 7:25you can fetch this content from here."
- 7:26I'm going to say, "Yes, and don't ask
- 7:28again."
- 7:29"Yes, and don't ask again." I'm giving
- 7:31it lots of permissions to go search
- 7:32things on the web. And here's how you
- 7:34can search. It's looking up for
- 7:35documentation. So, right now it's
- 7:37running all of these commands, which is
- 7:39looking for it's asking, you know, what
- 7:42are things here? What goes What's going
- 7:44on here? So, it's doing a lot of
- 7:45different tool commands all at the same
- 7:47time.
- 7:48Um and it's trying to figure out how to
- 7:50query Edgar
- 7:53um
- 7:54to do different things. So, I'm giving
- 7:56it a lot of permissions just so it can
- 7:57go and search and understand how to do
- 7:58this.
- 7:59This is a bit like what you and I would
- 8:01do if we were going and looking this up.
- 8:02It just reads faster than I do.
- 8:05Um
- 8:06So, it's working. It's working. It's
- 8:08working.
- 8:09Once it's kind of figured out how these
- 8:10tools work, it's going to then try to
- 8:12make a plan.
- 8:14So, it's figuring out, okay, well,
- 8:15here's the the different filing things.
- 8:17Here's what it's doing.
- 8:19>> [snorts]
- 8:20>> And so, it's it's searching. Still
- 8:22searching. You can see it's kind of
- 8:23refining what it's going on. And so,
- 8:24what the way to think about these is
- 8:26that
- 8:27these are each tools that it goes and
- 8:29does something and then it sends
- 8:30something back to the to the agent. And
- 8:33we actually don't see it in this window,
- 8:34but that's what it's doing. Now, it's
- 8:36it's trying to pull something from this
- 8:38person's GitHub page. I'm going to say
- 8:39yes. You can go look at that.
- 8:41But it's still making a plan, no?
- 8:44Okay, great. So,
- 8:45we had to stop really quick there,
- 8:47Marcus. Sorry about that. But one thing
- 8:48that's great about this is I interrupted
- 8:50while I was in the middle of this and
- 8:51that can happen for a number of reasons.
- 8:52Maybe you you kind of hit the button by
- 8:55accident cuz you have fat fingers or or
- 8:57you maybe your computer turns off or
- 9:00something like this. The amazing thing
- 9:02is cuz of we talked about how the
- 9:03context window works, you see it says
- 9:05interrupted, you know, what should
- 9:07Claude do instead cuz I hit escape. I
- 9:09can say, "Well, oh, please continue."
- 9:13So, it just says, "Oh, well, I'll just
- 9:14keep working then."
- 9:15So, I can just say this. It's going to
- 9:17say, "Okay, well, I'll just keep
- 9:18working. Let me research some more."
- 9:20>> it?
- 9:21So, I interrupted it when I when we uh
- 9:24Okay.
- 9:24>> So, it, you know, it's saying, "Oh, we
- 9:25have these errors." It's going to
- 9:27continue planning. Let's keep going. So,
- 9:29obviously there were some errors here
- 9:31that that occurred. It's going to keep
- 9:32working. It needs a user agent. So, I
- 9:35know the API well.
- 9:37So, it's going to do this. Let me
- 9:38clarify a few things before we do it.
- 9:40So, it It tried to do this and so now
- 9:42this is the coolest part of this. So,
- 9:43this is what one thing that's really
- 9:45lovely about Claude Code is it's It's
- 9:47going to ask me questions about how I
- 9:48want to do it. Remember when we did
- 9:49Claude Co-work, it did the same thing.
- 9:51Yeah. How do you want this structured?
- 9:53And so, do you want a SQL-like database?
- 9:56So, with things? Do you want a flat
- 9:58file? Do you want both?
- 10:00I'm actually going to tell it I want
- 10:01something called DuckDB,
- 10:03um which is very similar to a SQL-like
- 10:05database. It's just how I prefer to do
- 10:07things. Um
- 10:08So, you This is a fourth option. You can
- 10:10say DuckDB database,
- 10:12um please.
- 10:13Uh remember I'm very polite. So,
- 10:17then you could say, "Do you want a
- 10:18keyword search? Um extract the full text
- 10:20and then flag paragraphs?
- 10:22You want to extract the full section and
- 10:24do the keyword analysis later? Or do you
- 10:27want to do LLM classification, but then
- 10:29I would have to pay for it?" I'm going
- 10:30to do the keyword search. We're just
- 10:31going to look for words that are related
- 10:33to tariffs.
- 10:35Um
- 10:36and I And says, "What entity should we
- 10:38use for the user agent?" Remember you
- 10:40have to give this header. It's saying,
- 10:41"Do you want to fill it in later? Or do
- 10:43you want to do it right now?" I'm going
- 10:44to say I'm going to do it right now.
- 10:45I'll provide it.
- 10:47And then
- 10:49it's going to ask me. It's going to say,
- 10:50"Okay, well, please write your thing in
- 10:52now."
- 10:53And so, you know, you asked this before
- 10:55is that the planning takes a while. It's
- 10:57kind of similar to you'd say,
- 10:59um
- 11:00So, what name and So, So, what it's
- 11:02going to say is
- 11:03I It's saying, "Oh, it's very kind of
- 11:05interesting." It's saying, "Use
- 11:06placeholder text for now. I'll type it."
- 11:08And it's saying,
- 11:09"Write it here in number three." So,
- 11:11when it says, "I'll type it," it's
- 11:12saying, "Please put it here." So, I'll
- 11:14say, "My name is Paul Goldsmith Bingham.
- 11:16My email is [email protected]."
- 11:20So, I did that.
- 11:22And it's going to do this. So, it's
- 11:23going to put this here.
- 11:25And what we were talking about planning,
- 11:26what's really is kind of remarkable is
- 11:29with many projects, the plan is almost
- 11:31just as important as the execution. I
- 11:34see. Because sort of similar to like
- 11:37kind of when we do research, often what
- 11:39we're doing is trying to figure out what
- 11:41the plan is, right? Like we're just sort
- 11:42of saying we have a vague idea, let's
- 11:45iterate. When you work in a software
- 11:47engineer kind of setting, much of what
- 11:49you're doing is related to that. So,
- 11:50it's thinking really hard. You see how
- 11:52it if we went into here, it says, "Let
- 11:54me design this. I've all the info we
- 11:56need. Here's what we're going to do.
- 11:57Here's implement it. Here's my plan. I'm
- 11:59going to do this. It's going to do these
- 12:00targets."
- 12:02Um duck DB schema.
- 12:05Here are words I'm going to look for.
- 12:06Here's all these words. Now, I'm
- 12:08thinking through the target list I
- 12:10should do. If I'd given it a list, it
- 12:11would have been easier for it. So,
- 12:13retail, tech. Now, I need to figure out
- 12:16how to do this.
- 12:17I'm also thinking about what whether to
- 12:19use the API or just download the
- 12:21complete thing is better.
- 12:23So, I'm going to access the filing index
- 12:25through this, use beautiful soup, which
- 12:26is just a package to parse the HTML, and
- 12:28then look for something in the text.
- 12:30But, if I wanted to change something now
- 12:32as in oh, there was something wrong with
- 12:34Yeah, that's a great question. Yeah, so
- 12:35Yeah, so add another firm or something?
- 12:38Great. So, yeah, yeah. So, here's what
- 12:39we're going to do. So, here's the plan
- 12:41summary. So, we now have a plan, it
- 12:43says. Okay.
- 12:44>> So, remember how we talked about when
- 12:46there was this managed context window we
- 12:47were saying how it's useful to be in
- 12:49charge of it, like you do research, and
- 12:50then you can This is what we talked
- 12:52about in the first video.
- 12:53You would write down a plan. So, Claude
- 12:55has now kind of automated this directly.
- 12:57They're actually just plans I see.
- 12:59>> in here, and what it does in plan mode
- 13:00is it constructs a file, which is kind
- 13:02of the compressed memory of all the
- 13:04planning it did into an executable idea.
- 13:07Okay. So, here it's saying, "Here's the
- 13:09plan summary. I'm going to make a script
- 13:10that does looks for the CIKs for all of
- 13:12these.
- 13:14Then going to find them here. It's going
- 13:16to get all their filings, and I'm going
- 13:18to filter for 10-Ks. I'm going to
- 13:20download and parse each 10-K and look
- 13:22for item 1A. Mhm.
- 13:24>> I'm going to look for certain words, and
- 13:25then I'm going to store this in a
- 13:26database.
- 13:28And what it's going to do is it's going
- 13:29to cache the data, which means that
- 13:31after it's downloaded the HTML, it won't
- 13:33download it again. Remember we talked
- 13:34about this last time it was
- 13:35re-downloading things, which felt slow?
- 13:38This is a good example of it's just
- 13:39going to download all the raw data into
- 13:41a place so that it doesn't get stuck
- 13:44re-downloading every time.
- 13:46And then it's going to give lots of
- 13:47details what the plan is cuz this is the
- 13:48basically it's instructions to itself.
- 13:51So, it's going to say, "All right, I'm
- 13:52going to build a pipeline that does
- 13:53this.
- 13:54Here's the target companies, so it's
- 13:56going to be three different kinds.
- 13:58Here's the architecture. Here's how
- 14:00you're going to do it. This is just the
- 14:01longer version of what I described
- 14:02above.
- 14:03But that's where the one of the keywords
- 14:05I would like to instead of tariffs, I
- 14:07want to
- 14:08Yeah, you want to say you want to add
- 14:10another one. You want to say like "What
- 14:12if we added in Trump as well?" Like
- 14:14Trump or Yeah, so totally. So, we could
- 14:17say
- 14:18"Do you want it This is the plan. Would
- 14:19you like to do it?" And so, you could
- 14:21say yes, clear context, and auto accept.
- 14:23So, what that means is Mhm. Get Remember
- 14:26how you wipe the window and you just
- 14:27read the plan and go? One is you could
- 14:29say just yes, I'm going to I don't I I
- 14:31don't want to wipe it. I just want to go
- 14:32from here.
- 14:34Or yes, but I don't want to just auto
- 14:36accept what you're going to do. I see.
- 14:38Or four, what I'm going to say is
- 14:40"Please add in references to Liberation
- 14:44Day. Perhaps Liberation
- 14:45>> The Liberation Day. Great idea. Yes.
- 14:50Um to the tariff
- 14:52keywords.
- 14:57So, I It's going to say here, "Tool use
- 14:58rejected with this message. Please add
- 15:00in this." And it's thinking, "Good call.
- 15:02Liberation Day is very positive." Claude
- 15:04is always a very positive. With April
- 15:052nd, 2025 tariff now, let me update the
- 15:08keywords. So, add Liberation Day and
- 15:10Liberation Day tariff to the keyword
- 15:12list. And so, it's going to do that and
- 15:14it will put it here. Liberation Day,
- 15:15Liberation Day tariff.
- 15:17And everything else is pretty similar.
- 15:19It would be weird. So,
- 15:21for the interest of this, so I'm going
- 15:22to kind of
- 15:24um I'm going to say yes. I'm going to
- 15:25say go ahead and auto accept edits. So,
- 15:27that's going to let it write everything
- 15:29and do thing It won't be able to execute
- 15:30things, but it will be able to write and
- 15:32edit files on its own. So, but now it
- 15:35the
- 15:35you compress this everything, the old
- 15:37stuff, no?
- 15:39Yes, it will get rid of all the planning
- 15:40it did before when it clears the context
- 15:42window. That's side of what it's saying
- 15:44is it's going to clear all the old
- 15:45stuff, but it's going to save this plan
- 15:46that we just read through into a file.
- 15:48In fact, you can see it right here.
- 15:51Um it's going to edit It's going to have
- 15:53this plan right here as a file that it
- 15:55saves it. It actually keeps track of all
- 15:56your files, these these plans. And so,
- 15:59it says here I could actually
- 16:01>> this three meek knitting I call Yeah, so
- 16:03it just has The way that it does this is
- 16:05that it just combines three now three
- 16:07different words together. So, it's an
- 16:09adverb, noun, and noun.
- 16:11Um
- 16:12Um so,
- 16:15I'm going to say yes.
- 16:16Clear context and accept and accept
- 16:18edits.
- 16:20So, now it has this in here. Um
- 16:23and
- 16:25um
- 16:29Um and so, now it's running. So, it's
- 16:32going to write some information here.
- 16:34Um Thinking again essentially, but it
- 16:37had a plan already.
- 16:38>> Yeah, but the thinking The thinking is
- 16:39just that it's thinking about how to
- 16:40actually implement the plan. Now, it has
- 16:42It has a plan It has It knows how it
- 16:44wants to do it. Okay.
- 16:46>> Um
- 16:47It's And we can look at how it's
- 16:48thinking. It wants me to implement this.
- 16:50Let me create the files,
- 16:51requirements.txt. That's just for the
- 16:53packages, and then How did you switch on
- 16:56the thinking to looking into the
- 16:57thinking?
- 16:59Oh, thinking is just a word that it's
- 17:00using. So, it's like smooshing or
- 17:02anything. This is just random verb or
- 17:04>> if you want to look into the thinking
- 17:05process Oh, I'm sorry. Great question.
- 17:07Yes, I should have said this. So, if you
- 17:09hit control O, it will show the what's
- 17:11thinking. And if you hit control O
- 17:13again, it will go back. That's my I
- 17:15should have said that. Yeah.
- 17:16>> What does the O stand for? Just as a I
- 17:19think just open probably is the easiest
- 17:21way to think of that. Like it opens up
- 17:23all the stuff that's going on behind the
- 17:24scenes.
- 17:25>> I see. Um so here I just wrote a bunch
- 17:27of code. It wrote 480 so it just wrote
- 17:29all this script here. It's a Python
- 17:31script that just wrote all of this. You
- 17:33know, it has all the phases that we
- 17:35talked about. So here's phase one that
- 17:37does the look up. Mhm. It has all I mean
- 17:39this is all code that would take a
- 17:40little while to write yourself and did
- 17:42it, you know, in just a minute or two.
- 17:44>> to be able to double-check this code or
- 17:45you just run with it?
- 17:47I mean it's sort of the benefit is that
- 17:48if it if you have a way of knowing that
- 17:50it worked correctly, that's helpful. So
- 17:52you should know that it's going to pull
- 17:54uh you know, three five three to four
- 17:56filings for 30 companies. So you should
- 17:58know you should have 128 five like rows
- 18:01of filing information. Okay.
- 18:03>> And so that's one way to know. So now
- 18:05it's going to just do Now it's going to
- 18:06try and run stuff. So here it's
- 18:07installing dependencies. Mhm. Um
- 18:13And so I it's going to say, "Hey, you
- 18:14already have these things so you don't
- 18:16need it." So I didn't need to install
- 18:17anything new and that's going to run
- 18:18this scraper.
- 18:20It will take several minutes since it
- 18:21downloads 90 plus filings. I don't know
- 18:23if that's true.
- 18:25Um so it could not find something. So
- 18:29it's actually running here in the
- 18:30background. This is
- 18:32Um could not find the CIK for this
- 18:34company.
- 18:35I see.
- 18:36>> Now it's downloading here. So it did a
- 18:38bunch very quickly. Here's a 30. It just
- 18:41It's looking for the filings. Mhm.
- 18:44And it's gotten most of those. So this
- 18:46is figuring out where all the filings
- 18:48are and now it's downloading the actual
- 18:49documents.
- 18:51So this is actually this is
- 18:53coming from its own command line that
- 18:55it's running. It's running this
- 18:56It downloader here. It's downloading and
- 18:58extracting information. So it We're
- 19:00missing it for a few I think we're
- 19:02missing it for one company.
- 19:04So it has all but one and so it's
- 19:07running here. Now we're up to 22 26%.
- 19:11It's downloading. Can I ask get laid on
- 19:13which company the CIK stands for which
- 19:15company?
- 19:17Oh, this GPA the one that it missed?
- 19:19Yes. Yeah. Um,
- 19:20we can So, one thing that's nice is you
- 19:22can queue your um questions. You could
- 19:25say, "What company was it unable to find
- 19:29a CIK for?" Okay. And so, and then you
- 19:32could you can edit it if you if you
- 19:34change your mind, you can press up to
- 19:36edit it. Um Okay.
- 19:40Oops, sorry.
- 19:43And so, that will answer it. So, we're
- 19:45almost done, 93%. And so, what's nice is
- 19:47you could go and um look at the folder
- 19:50really quick. Um
- 19:52So, if we go and look in the folder
- 19:55um well, I guess I won't do this cuz I
- 19:57don't want to
- 19:58It's what I can tell you is it's
- 19:59downloaded 116 of these already. So, it
- 20:02it did it. It's running this command and
- 20:04it's it's here.
- 20:06Um the pipeline ran successfully. Here's
- 20:08the summary.
- 20:10It did 29 out of 30. Do you So,
- 20:15And GPS is Gap Inc. It's the one ticker
- 20:18it couldn't find a CIK for. That's
- 20:19because GA Gap Inc. rebranded and it's
- 20:21now traded under Gap in some data sets.
- 20:23So, we can look If you would like, I can
- 20:26look up the correct ticker mapping and
- 20:27add it. Yes, please add it.
- 20:31Okay.
- 20:32So, now we'll see what it does in
- 20:33response to this question.
- 20:36Um
- 20:39And it will go and it will look. So,
- 20:41what it's doing is it's looking in the
- 20:42SEC Edgar
- 20:44and the company tickers of where Gap is.
- 20:48Um
- 20:50So, I'm giving it permission to do this.
- 20:54And
- 20:56See if I can Pretty cool.
- 20:59Yeah. So, it's searching. It's trying to
- 21:01figure out what its CIK is. It looks
- 21:02like it's done.
- 21:04Um
- 21:05CIK 39911 Let's see Let's me check why I
- 21:09did. Was it case sensitivity or
- 21:11something else?
- 21:14And it looks like it was because it was
- 21:15GAAP.
- 21:17Mhm. Not GPS. And so I'll update the
- 21:19script to use GAAP instead. And so it's
- 21:22going to change it in here to be
- 21:23correct. Now let me rerun. Since it's
- 21:25cached, it's only going to download one
- 21:27file. Okay. Okay.
- 21:29So it should be very quick. Yes, it's
- 21:30cached.
- 21:32Only four new files. It was about 43
- 21:34seconds. The cache files are written
- 21:35here. Da da da. Okay. So now it only So
- 21:39now we can ask the next question which
- 21:40it said, "Okay, well we only got 112 out
- 21:43of the 120 sections extracted Mhm. with
- 21:46113 tariff paragraphs. So
- 21:49um why didn't we get 120 item
- 21:54uh one paragraphs?
- 21:57So it seemed like we are missing a few
- 22:00without these.
- 22:01Um good call. Eight filings failed the
- 22:04item 1A extraction.
- 22:06So let me check which ones. It's going
- 22:08to check. Looks like it's from several
- 22:10of these ones that um are Honeywell and
- 22:13Intel. Every filing for both the regex
- 22:16must not be matching what they're doing.
- 22:18So there's an element to which if you
- 22:19know it's mandatory to have these one
- 22:21check is to say, "Hey, every year there
- 22:23should be an an item for this." Yeah. So
- 22:26figure out what's going on.
- 22:28And so it's writing this code. I'm, you
- 22:30know, the joke with these LM things is
- 22:31often you just hit enter. You don't even
- 22:33look at the code every time because
- 22:34there's so many things it's going to
- 22:35check. Um but obviously, you know,
- 22:38So in both of these, item 1A and risk
- 22:41factor are on separate lines with a new
- 22:42line between them. The current regex
- 22:44requires them to be on the same line.
- 22:45The fix is to allow new lines.
- 22:47Uh it's going to do some work here to
- 22:49fix this. Regex, if you're not familiar,
- 22:51is just a way to look for patterns in
- 22:52string. Now it's going to rerun it. So
- 22:55um after you're done with this, instead
- 22:59of trying to
- 23:01fix these two, can you show how uh uh um
- 23:06how much uh which
- 23:10firms are most um
- 23:12mentioning
- 23:14um tariffs with
- 23:17Uh you always Can you show the show is
- 23:19missing?
- 23:22Oh, yes. Thank you. It probably wouldn't
- 23:24even care. Can you it would say it would
- 23:27probably make its best guess.
- 23:29Okay. Let's see how it did. Big
- 23:31improvement. 119.
- 23:33So, it's going to keep trying to do
- 23:35this. It's still trying to figure it
- 23:36out.
- 23:37But,
- 23:38it's just 3M now.
- 23:40He's managed to break 3M.
- 23:43So, it's going to say it's likely in a
- 23:44filing formatting edge case.
- 23:46Mhm.
- 23:46>> 10K might have unusual structure. Yada
- 23:48yada yada.
- 23:50Um let's proceed. I'm going to ask it to
- 23:52do this thing. It's going to look and
- 23:54it's going to say
- 23:55what's the top word So, it's going to
- 23:57give me some information. Mhm.
- 23:59It wrote a script to do this. And so,
- 24:01what here's what it'll do. So, I said
- 24:03um which firms mention tariffs the most?
- 24:07The ones that mention it the most are
- 24:09manufacturing. So,
- 24:10um
- 24:11Deere John Deere leads with the most
- 24:13tariff mentions increasing from three to
- 24:15four over time.
- 24:16Manufacturing tech hardware retail firms
- 24:18mention it the the least.
- 24:21They both jumped to three.
- 24:22It AVGO dropped from four to zero. Mhm.
- 24:26And Walmart's only started mentioning
- 24:27tariffs in 2025. Oh, yeah. So, most
- 24:30paragraphs have it.
- 24:33So, it's it shows up more. So, the
- 24:34question is is please download the 10Ks
- 24:40for um 2010
- 24:43um for these same firms and identify
- 24:48um
- 24:49the um um
- 24:51um identify the tariff
- 24:54measures there as well.
- 24:57It looks like even in 2010 it mentions
- 25:00it. Mhm.
- 25:01Um so, we're going to sort of see even
- 25:04in 2010, you know, 18 companies mention
- 25:07it. Okay.
- 25:09So, it looks like, you know,
- 25:12it was already widespread here, but the
- 25:14intensity has increased. More paragraphs
- 25:15per company in previous years. Not sure
- 25:18if that's So, 25 across 18 versus 26 to
- 25:2135 per year in in roughly the same
- 25:24number.
- 25:25In 2010 it was narrower, mainly tariff,
- 25:27trade restrictions, anti-dumping,
- 25:28countervailing. Now it's, you know,
- 25:30trade tension, trade dispute, trade war.
- 25:33I see. Um
- 25:35and so on. So, you know, you could do a
- 25:37lot more with this. It's sort of
- 25:38interesting. I don't think something
- 25:39that I was aware of of kind of how
- 25:41common it is. I think the next thing if
- 25:42I was going to do this, which we could
- 25:44do some other time or
- 25:45you, the viewer, can do is you could do
- 25:48this for a lot more firms. I mean, I
- 25:49think the biggest difference that's
- 25:50happened here, right, is that in this
- 25:52time period there's just far more um
- 25:55things going on. It's hitting a lot more
- 25:57firms and so understanding the
- 25:59cross-section of firms here would be
- 26:00very interesting. Right.
- 26:02>> So, um hopefully this is interesting. I
- 26:05think one of the things that you're
- 26:06interested in thinking about macro risks
- 26:08and doing this, parsing this kind of
- 26:10data, the cost I mean, we did this in
- 26:12about 30 minutes
- 26:13is way lower and you could start
- 26:15thinking about other risk factors and
- 26:16other things to do. It doesn't require a
- 26:18team of RAs or anything else and
- 26:19hopefully, you know, this could be
- 26:21useful for you going forward in the
- 26:22future.
- 26:23Fantastic.
- 26:25All right.
- 26:29Great.
- 26:30So,
- 26:32I think with that, I think we'll wrap
- 26:34up, Marcus, unless you have anything
- 26:35else you wanted to add. I think just to
- 26:37summarize, we basically we did and ended
- 26:41up taking um a little bit more than our
- 26:43usual time, but we we basically
- 26:46worked with this LLM to kind of cons-
- 26:49ask a question of Edgar, which is a the
- 26:52Securities and Exchange Commission's
- 26:54website. We downloaded a bunch of
- 26:56basically raw filing data and asked
- 26:58Claude to write parsing scripts for us.
- 27:01It put it into structured database and
- 27:03then we were able to ask questions in a
- 27:05pretty quick amount of time. So, next
- 27:07time we're going to think about much
- 27:08bigger data sets and how to structure
- 27:10them and I'm looking forward to joining
- 27:12them.
- 27:13That is good. Thanks a lot, Paul, and
- 27:15thanks for all of you for following and
- 27:18be excited about the next mini video
- 27:21um
- 27:23coming up soon.
- 27:24Cheers.
- 27:25>> Great. Bye-bye.
- 27:26>> Cheers. Bye-bye.
About this transcript
This page contains the full transcript of Web scraping: Claude Code for Economists with Paul Goldsmith-Pinkham | Markus Academy | Ep. 162-3 by Markus' Academy, generated from the public captions YouTube serves with the video. The transcript has 5,554 words across 859 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.