rss-feedmonitor/scripts/generate_optimized_rss_feed...

200 lines
9.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Optimized Reddit RSS Feed Generator for Canadian Repair Keywords
This script generates the most impactful search RSS feeds for Canadian subreddits,
focusing on high-conversion repair scenarios with minimal overlap.
"""
import urllib.parse
import json
from pathlib import Path
class OptimizedRSSGenerator:
def __init__(self):
self.base_search_url = "https://www.reddit.com/r/{}/search.rss?q={}&sort=new&type=link"
# Top-priority search combinations based on repair lead potential
self.top_searches = {
"iphone_repairs": {
"name": "iPhone Repair Requests",
"query": '("iPhone" OR "iPhone 12" OR "iPhone 13" OR "iPhone 14" OR "iPhone 15") AND ("repair" OR "fix" OR "broken" OR "not working" OR "screen broken" OR "won\'t charge" OR "water damage" OR "looking for repair")',
"description": "Most common iPhone repair requests"
},
"macbook_repairs": {
"name": "MacBook Repair Requests",
"query": '("MacBook" OR "MacBook Pro" OR "MacBook Air") AND ("repair" OR "fix" OR "broken" OR "not working" OR "won\'t turn on" OR "keyboard" OR "screen" OR "water damage")',
"description": "MacBook hardware repair needs"
},
"laptop_repairs": {
"name": "Laptop Repair Requests",
"query": '("laptop" OR "computer" OR "notebook") AND ("repair" OR "fix" OR "broken" OR "not working" OR "won\'t turn on" OR "screen broken" OR "keyboard" OR "charging")',
"description": "General laptop repair discussions"
},
"phone_repairs": {
"name": "Phone Repair Requests",
"query": '("phone" OR "cell phone" OR "smartphone") AND ("repair" OR "fix" OR "broken" OR "screen" OR "charging" OR "water damage" OR "not working")',
"description": "General phone repair needs"
},
"console_repairs": {
"name": "Gaming Console Repairs",
"query": '("PS5" OR "PS4" OR "Xbox" OR "Nintendo Switch" OR "PlayStation" OR "gaming console") AND ("repair" OR "fix" OR "broken" OR "not working" OR "disc drive" OR "HDMI")',
"description": "Console repair and maintenance"
},
"data_recovery": {
"name": "Data Recovery Requests",
"query": '("data recovery" OR "hard drive" OR "SSD" OR "lost files" OR "recover data" OR "drive failed" OR "storage failed")',
"description": "Data recovery and storage repair"
},
"general_repairs": {
"name": "General Repair Services",
"query": '("looking for repair" OR "need repair" OR "repair shop" OR "repair service" OR "local repair" OR "professional repair" OR "fix my")',
"description": "General repair service requests"
}
}
# Canadian subreddits by priority (comprehensive but focused)
self.subreddits = {
"critical": ["toronto", "vancouver"],
"high": ["calgary", "edmonton", "montreal", "ottawa"],
"medium": ["hamilton", "kitchener", "londonontario", "winnipeg", "victoria", "halifax"],
"expansible": ["saskatoon", "regina", "saskatchewan", "alberta", "britishcolumbia", "ontario", "quebec"]
}
def generate_optimized_feeds(self):
"""Generate optimized RSS feeds for each subreddit"""
feeds = {}
for priority, subs in self.subreddits.items():
feeds[priority] = {}
for subreddit in subs:
feeds[priority][subreddit] = []
for search_key, search_data in self.top_searches.items():
encoded_query = urllib.parse.quote(search_data["query"])
url = self.base_search_url.format(subreddit, encoded_query)
feeds[priority][subreddit].append({
"name": search_data["name"],
"query": search_data["query"],
"url": url,
"description": search_data["description"],
"category": search_key.replace("_", " ").title()
})
return feeds
def generate_markdown_output(self):
"""Generate clean markdown output"""
feeds = self.generate_optimized_feeds()
output = []
# Header
output.append("# 🚀 Optimized Canadian Repair RSS Feeds")
output.append("")
output.append("**Strategy:** High-impact searches covering 90% of repair opportunities")
output.append("**Coverage:** 7 key repair categories across priority Canadian cities")
output.append("**Total Feeds:** Manageable daily monitoring workload")
output.append("")
output.append("---")
output.append("")
total_feeds = 0
# Process each priority level
for priority, subreddits in feeds.items():
priority_title = priority.upper()
output.append(f"## {priority_title} PRIORITY SUBREDDITS")
output.append("")
for subreddit, feed_list in subreddits.items():
output.append(f"### r/{subreddit}")
output.append("")
total_feeds += len(feed_list)
for feed in feed_list:
output.append(f"#### {feed['name']}")
output.append("")
output.append(f"**Category:** {feed['category']}")
output.append(f"**Description:** {feed['description']}")
output.append("")
output.append(f"**Search Query:**")
output.append(f"```\n{feed['query']}\n```")
output.append("")
output.append(f"**RSS URL:**")
output.append(f"```\n{feed['url']}\n```")
output.append("")
output.append("---")
output.append("")
output.append("")
# Summary and implementation
output.append("## 📊 IMPLEMENTATION SUMMARY")
output.append("")
output.append(f"- **Total RSS Feeds:** {total_feeds}")
output.append(f"- **Subreddits Covered:** {sum(len(subs) for subs in self.subreddits.values())}")
output.append(f"- **Search Categories:** {len(self.top_searches)}")
output.append("")
# Quick start guide
output.append("## 🎯 QUICK START GUIDE")
output.append("")
output.append("### Phase 1: Start Small (Week 1)")
output.append("1. **Pick 1 city** (start with Toronto)")
output.append("2. **Subscribe to 3 feeds:** iPhone, MacBook, and General Repairs")
output.append("3. **Monitor daily** for 1 week")
output.append("4. **Engage with 1-2 conversations** per day")
output.append("")
output.append("### Phase 2: Scale Up (Week 2-4)")
output.append("1. **Add Vancouver** (your second critical city)")
output.append("2. **Add 2 more feeds** per city (Laptop, Data Recovery)")
output.append("3. **Total: 10 feeds** across 2 cities")
output.append("")
output.append("### Phase 3: High Priority Expansion (Month 2)")
output.append("1. **Add Calgary, Edmonton, Montreal, Ottawa**")
output.append("2. **Start with top 3 feeds** per city")
output.append("3. **Total: ~24 feeds** across 6 cities")
output.append("")
output.append("## 💡 SUCCESS METRICS")
output.append("")
output.append("- **Daily Posts:** 5-20 relevant posts per feed")
output.append("- **Weekly Leads:** 3-10 repair opportunities")
output.append("- **Engagement Rate:** Reply to 1-2 conversations daily")
output.append("- **Conversion Rate:** Track repair business generated")
output.append("")
output.append("## 🔧 RSS READER SETUP")
output.append("")
output.append("### Recommended Tools:")
output.append("- **Feedly** (web/mobile, great organization)")
output.append("- **Inoreader** (powerful filtering)")
output.append("- **NetNewsWire** (macOS native)")
output.append("")
output.append("### Organization Tips:")
output.append("- Create folders: `Critical Cities → Toronto → iPhone Repairs`")
output.append("- Set notifications for new posts")
output.append("- Use starring/bookmarking for follow-up")
output.append("- Archive weekly to stay organized")
return "\n".join(output)
def save_to_file(self, filename="optimized_rss_feeds.md"):
"""Save the markdown output to a file"""
output = self.generate_markdown_output()
with open(filename, 'w', encoding='utf-8') as f:
f.write(output)
total_feeds = sum(len(self.top_searches) * len(subs) for subs in self.subreddits.values())
print(f"✅ Generated {filename} with {total_feeds} optimized RSS feeds")
print("🎯 Ready for high-impact Canadian repair lead monitoring!")
print(f"📊 Coverage: {len(self.subreddits)} priority levels × {len(self.top_searches)} search categories")
def main():
generator = OptimizedRSSGenerator()
generator.save_to_file()
if __name__ == "__main__":
main()