Scrapy with JavaScript & Dynamic Content: When Your Selectors Return Nothing
dev.to·1w·
Discuss: DEV
🕵️Feed Discovery
Preview
Report Post

I’ll never forget the first time I tried scraping a modern website. My selectors worked perfectly in the browser’s inspector. But when I ran my spider, everything returned None.

I checked my CSS selectors ten times. I tried XPath. Still nothing. I was going crazy.

Then I viewed the page source (Ctrl+U) and realized: the content wasn’t there. The HTML was nearly empty. Everything was loaded by JavaScript after the page rendered.

That’s when I learned: Scrapy doesn’t run JavaScript. It only sees the initial HTML. Let me show you how to handle JavaScript-heavy sites.


The Problem: Scrapy Doesn’t Run JavaScript

When you visit a website in a browser:

  1. Browser downloads HTML
  2. Browser runs JavaScript
  3. JavaScript fetches data (AJAX)
  4. JavaScript builds the p…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help