-: Okay, I'm gonna run you
through how to do analysis of a publication.
The publication I'm looking at today is Lenny's blog.
As you can see,
here are the top posts on Lenny's blog
and I wanted to scrape all of these
and basically summarize what are the sorts of things
that this blog is talking about.
What are some insights I can get?
And if I was pitching this blog or similar publication,
what sort of titles
should I pitch them that would be interesting?
Or potentially what templates are working well for them
that I can use for my own blog?
Okay, so let me show you how this works.
First, I'm gonna install Anthropic,
so I have that running
and going to load the environment,
and that's where I have my OpenAI API key.
I'm just gonna do that in a second.
I'm just gonna pull in here the blog posts.
So this is what you need to get from scraping
and this isn't the scraping tutorial.
This is more on the analysis
and to be honest,
I don't really know that much about web scraping.
I literally just asked ChatGPT
and this is the code that it gave me
to scrape the blog.
And if we go,
let's see, if we pop open this blog again,
let's see if this code still works.
I'm just gonna paste into,
here we go, data copied to clipboard
and basically what this has done
is pasted all the different blog posts and titles.
And what I've then done is put that into this CSV,
paste it into here,
and it's got all the titles,
it's got when it was published,
what the author is, et cetera.
That is what I did for scraping.
I literally just asked ChatGPT to write that code for me,
so I can't teach you that much about web scraping.
But once you have all the posts in here,
then you can download them
and I've done that down here.
So you can see it downloaded all the texts from each post.
Yeah, and the way I've done that just to show you
is if you load the links
and then you get a list of the URLs,
and this is going, just to show you,
it's going through each URL
and it's getting the link
which is the second part,
and then it's finding the file name,
and then it's just reading the text using Beautiful Soup
and then just saving that text locally.
So that's how I downloaded everything
and I just sleep for three seconds here.
It depends on the website.
Again, I'm not a web scrap pro.
I'm not particularly good at this.
This isn't a web scraping tutorial.
Yeah, basically this was also written by ChatGPT,
but if I run into an error,
I just ask ChatGPT
and it will fix it.
So if that's how that works,
so that will download the different URLs.
You'd have them all the text in here.
So that's a prerequisite.
I'm just going to interrupt that
'cause I've already done that part
and it took I think a maybe about an hour
to download this stuff.
All right, so now onto the actual tutorial though
which is how do we summarize this text?
So just gonna load Anthropic first.
Make sure this is working.
Yeah, here we go.
So the way you call Anthropic,
this is Clause Three is you set up the client,
it gets the API key that you determined.
If I just close this,
in your .env file.
I won't show you mine,
but you just need to have something
called Anthropic_API_KEY and then equals
and then the actual key that you get from Anthropic.
But assuming you have that,
then it will load Anthropic
and then you can get, it's very similar to OpenAI API.
You can just specify the model
and then you send the messages.
And I just said, "Hello,"
and it said, "Hello, how can I assist you?"
That's how I know it's working.
Now what I need to do to analyze this
is to just loop through
and pull out different texts from this folder
and then place that into the prompt
and then here, I'm just asking you
to pull out one non-obvious insight from this text.
So it's basically reading the text
and then coming back to me with something interesting.
So let's see how this works.
Okay, so that took 46 seconds for five URLs.
Obviously we could do it for everything,
but here we go.
From this blog post,
it said that borrowing successful features
from other products requires
carefully adapting them to your specific context
and it has a quote here which is pretty cool.
This one, "How the biggest consumer apps
got the first 1,000 users,"
they found the early users from just a single strategy.
That's pretty surprising, right?
Another one here is that ChatGPT
is good for non-engineering teams,
not just engineering teams.
So summarizing customer interviews,
identifying regarding pain points,
finding compelling customer testimonials,
generating action items.
I think that's pretty interesting,
but this is a great way to decide
whether you wanna read the post in the first place
and also to start to notice patterns
about what types of things
are being written about on this blog.
That's quite cool, I find that quite useful.
You could also change the prompt to say whatever you want.
So you could ask it to give you a summary
or to highlight what the quote is about
or whatever it is.
Pull out bullet points
or whatever you would like to do.
But where it gets really interesting is the Claude
has a 200,000 token limit in terms of the context windows.
So you can fit
pretty much an entire Harry Potter book in there
and therefore you can just pull
a bunch of these texts together
and start to look for patterns.
What I did here is if you run this,
it just pulls out the first 50 URLs
and then it appends the text into tags here,
and then it's just telling me how many words basically,
how many tokens is an estimate.
One token is roughly four characters,
so just counted here.
So I'm just under 200,000 which is great.
If I look at that one,
all texts, you can see that it starts with article
and then it has all the texts.
I could probably strip out some of this white space
and then it divides the articles with a line like this.
And the reason I'm using these tags like this,
it's almost like HTML,
is that Claude was trained on tags
and responds really well for them.
So that's just a specific Claude thing
that I recommend you do.
You just get better results
'cause it delineates the specific things
that you're talking about.
In this case, the articles.
So now what we're gonna do
is we've got all of our text here,
so we're reading all text
and then we're sending to Claude Opus.
We're saying summarize these articles,
analyze the word choice, identify any patterns,
and tell me about any non-obvious insights publications.
So now we're passing in all of those articles,
50 articles, the full text of each,
all in one prompt which is pretty cool
and we'll just see what it comes back with.
Okay, we've got the response.
It took about two minutes
because this is a smart model
and therefore it's relatively slower,
but also we're passing it a ton of text, right?
So the longer the prompt,
the longer the time it takes to get back to you.
So analyze these articles.
It did hallucinate, it thinks there's 40 articles,
but there are actually 50.
It's not very good at accounting,
and it summarizes, so it says they cover
a wide range of topics related to product management,
growth, career development, entrepreneurship
and then it gives some common themes,
tactical advice and frameworks, inside stories.
Interviews with experienced leaders,
guidance for early-stage startups,
and personal stories of career journeys.
So already I know if I wanted to do a guest post for Lenny
and I was coming up with new ideas,
I could take a look here.
The content's highly practical, example-driven,
and grounded in real-world experience
so that's important to know.
They go deep on specific topics.
The word style is conversational, direct,
and easy to follow whilst covering complex topics.
There's also frequent characteristics of the writing,
so this is gonna help you get past the editing process
if you are writing a post for this publication.
But again, this could be used for any publication
or even to analyze your own blog
to understand what's interesting about it.
Frequent use the second person "you"
to speak directly to the reader.
A liberal use of bolded numbered lists,
bolding of key phrases,
relatively simple vocabulary, et cetera.
And then the writing is more casual
and bloggy in style compared to traditional business writing
and the there's also more information here.
Kept going, it figured out the reading level.
Some non-obvious patterns, his own writing accounts
for less than half the articles, that's pretty interesting.
And there many compendium-style posts like best-ofs.
There is also failure stories as much as success stories,
organic, product-led growth over a paid acquisition.
Very little mention of ads, that's useful to know.
The design is very rarely mentioned.
That's actually surprising to me
considering it's a product management-focused blog.
Analytics and metrics are important
and there's a bias towards VC-backed startups.
So that's really interesting to know
and maybe some of these things
Lenny himself might not have realized.
Well, now the other thing I wanted to do
is just get all the titles
and think about what a successful title might look like
if I was pitching Lenny to join his blog as a guest speaker.
This is a prompt I've used a bunch of times in the past.
It's based on this thing called the Blank.
This is from a Tim Ferriss interview with James Clear,
the author of "Atomic Habits."
He found when he looked
at all the most successful titles of business books,
that this was a successful template.
"The War of Art,"
"The Psychology of Money,"
"The Subtle Art of Not Giving a --."
Basically you take two things
that are not normally associated
and then put them together,
the blank of blank.
"Odd Topic" is the template he chose for his book,
so habits are not normally atomic.
This doesn't have the blank of blank.
Instead it's just a odd combination.
"Extreme Ownership," ownership's not normally extreme.
"Deep Work," work is not usually deep.
So that's what James Clear choose
and then I just added this one as well.
I was using this prompt
to come up with the title of my O'Reilly book
and this is an example of the type of O'Reilly books.
So if you're not getting good success,
by the way, with this template,
you can just add multiple new templates into here
that cover the types of things you wanna see
and then it will do a much better job
for that specific publication.
All right, what we're trying to do,
we're passing it all the titles
and we just wanna see what types of templates come back
in terms of what are the types of titles
that appear on Lenny's blog.
So it's gonna come up with its own templates like this
if it works well.
Okay, here we go, have some templates.
"How X does Y"
and giving some examples.
How Duolingo reignited user growth,
how Linear builds product,
how Shopify builds product.
That's pretty interesting to me.
Tells me if I work for a successful company like Duolingo,
I could do something similar to that.
I just choose a specific topic
and they say how this company does X.
"How to X," how to use ChatGPT,
how to validate your B@B startup idea,
how to pass a first-round interview.
So that's pretty interesting,
and "The X of Y" or "The X Y."
So if the first word is an adjective
or noun describing an important aspect
and then that's related to the main topic.
So the 10 commandments of salary negotiation,
the ultimate guide to willingness-to-pay,
the unconventional Palantir principles.
And then "X for Y."
So good strategy, bad strategy, okay.
There's some interesting templates in here
and you'll get slightly different ones
if you run it again and again,
but this is a pretty useful prompt I found
just to get really good templates out of titles
and it gives you a good sense
of what are the types of things you should start looking at
over time in order to hitch this blog
or maybe just learn from what works for this blog
because if they're using
the same sort of template again and again,
it's because it's working.
The editor thinks it's working.
Either they'd know and they're doing it consciously
and they're going out finding other examples
or they don't know,
and it just happens to be successful
and it's something you can learn from as well.
So if you're pitching a publication to guest posts
or if you're just trying to understand
what makes a publication successful,
these combination of prompts
combined with some web scraping is really helpful.