You Don't Necessarily Need Both!
For this specific task, you only need Scrapy since it handles both HTTP requests and HTML parsing. Here's a cleaner approach without extra dependencies:
Revised Setup (Scrapy Only)
pip install scrapy
Modified Spider Code (hotleak_spider.py)
import scrapy
class HotleakSpider(scrapy.Spider):
name = "hotleak_spider"
start_urls = ["https://hotleak.vip/"]
custom_settings = {
'DOWNLOAD_DELAY': 2, # Be polite to the server
'USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}
def parse(self, response):
# Count video thumbnails using Scrapy's built-in selectors
video_count = len(response.css('div.thumb-block'))
if video_count >= 20:
yield {
'page_url': response.url,
'video_count': video_count
}
# Pagination handling
next_page = response.css('a.next-page::attr(href)').get()
if next_page:
yield response.follow(next_page, callback=self.parse)
Key Changes:
-
Removed BeautifulSoup/Requests - Using Scrapy's native CSS selectors:
response.css('div.thumb-block') finds all video containers
response.css('a.next-page::attr(href)').get() gets next page URL
-
Added User-Agent - Helps avoid blocking
-
Simplified Workflow - No extra libraries needed
To Run:
scrapy crawl hotleak_spider -o results.json
If You Prefer a Simpler Solution (Without Scrapy)
Use this requests + built-in lxml solution (requires 2 lightweight packages):
pip install requests
import requests
from lxml import html
url = "https://hotleak.vip/"
results = []
while url:
response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'})
tree = html.fromstring(response.content)
# Count videos
video_count = len(tree.xpath('//div[@class="thumb-block"]'))
if video_count >= 20:
results.append({'url': url, 'count': video_count})
print(f"Found: {url} ({video_count} videos)")
# Get next page
next_btn = tree.xpath('//a[@class="next-page"]/@href')
url = next_btn[0] if next_btn else None
# Save results
import json
with open('results.json', 'w') as f:
json.dump(results, f)
Which to Choose?
| Approach | Dependencies | Best For |
|---|
| Scrapy | Only Scrapy | Large-scale crawling with pagination |
| Requests | requests | Quick one-time scraping |
Both will give you a results.json file with pages containing 20+ videos. The Scrapy version is more robust for large sites, while the Requests version is quicker for small tasks.