I Built a C# AI Agent That Scrapes the Web (Without Getting Blocked)
TheCodeMan - Stefan Đokić
0:00 / 0:00
I Built a C# AI Agent That Scrapes the Web (Without Getting Blocked)
1 625 просмотров · 2 нед. назад
TheCodeMan - Stefan Đokić
4,14 тыс. подписчиков
1 625 просмотров · 2 нед. назад
Try Decodo (free plan): https://visit.decodo.com/Ag1yDR
Learn AI for .NET Developers: https://www.skool.com/ai-for-dotnet-d...
Get Source Code for free (and much more): https://www.skool.com/thecodeman-comm...
Join the Newsletter list along with 23k+ engineers: https://thecodeman.net/
I thought scraping a website in C# would be easy.
One HttpClient. One GetStringAsync. Done.
It worked for about 3 requests - then came the 403s, the CAPTCHAs, and pages that returned nothing because the real content was rendered by JavaScript my HttpClient never ran.
In this video, I'll show you how to pull clean data from a site that fights back - straight from C# using the Decodo Web Scraping API - and then how to build a .NET AI agent that scrapes the live web on its own through Decodo's MCP server, without me writing a single line that says how to scrape.
Decodo handles the hard part for you: a pool of 125M+ residential IPs across 195+ locations, JavaScript rendering, and anti-bot / CAPTCHA handling - so one POST request returns the real, rendered page.
We'll go through:
Why a raw HttpClient scraper gets blocked (IP reputation, anti-bot, JS rendering)
Calling the Decodo Web Scraping API from C# (geo-targeting, JS rendering, structured output)
Turning any page into clean, AI-ready Markdown
What the Model Context Protocol (MCP) is, in .NET
Connecting a C# AI agent to Decodo's hosted MCP server with Microsoft.Extensions.AI
Letting the model decide when to scrape and reason over live data
The no-code path with the Decodo n8n integration
Stack used:
.NET 10
Console app + Minimal setup
HttpClient
ModelContextProtocol (official C# SDK)
Microsoft.Extensions.AI
Decodo Web Scraping API + hosted MCP server
This is not a full beginner tutorial where we build everything from scratch. The goal is to show a realistic, production-style scraping workflow in C#, and how an AI agent fits into it through MCP.
Check my courses and ebooks:
Pragmatic .NET Code Rules Presale: https://thecodeman.net/pragmatic-dotn...
Design Patterns Written Course 1: https://thecodeman.net/design-pattern...
Design Patterns Ebook 2: https://thecodeman.net/design-pattern...
Get for free:
.NET Roadmap 2026: https://thecodeman.net/dotnet-roadmap...
Start project Kit: https://thecodeman.net/dotnet-code-ru...
AI in .NET Kit: https://thecodeman.net/ai-in-dotnet-s...
Pass Your .NET Interview: https://thecodeman.net/pass-your-inte...
Vertical Slice Architecture: https://thecodeman.net/vertical-slice...
Social Media:
LinkedIn: /djokic-stefan
X: https://x.com/TheCodeMan__
GitHub: https://github.com/StefanTheCode
Medium: /thecodeman
Instagram: /thecodeman___
Chapters:
0:00 Intro - Basic Scraping
0:40 Fix - Decodo
3:40 Decodo Live Demo
6:45 Scraping with MCP
12:05 Recap