|
| 1 | +import os |
| 2 | +import re |
| 3 | + |
| 4 | +def verify_seo(): |
| 5 | + base_dir = 'c:/Users/PMLS/Desktop/Youtube Shorts/b2b_blog' |
| 6 | + report_path = 'c:/Users/PMLS/.gemini/antigravity/brain/8acb5e45-297b-4c05-ae50-1d7cdeac50b0/seo_affiliate_report.txt' |
| 7 | + |
| 8 | + with open(report_path, 'w', encoding='utf-8') as report: |
| 9 | + # Check robots.txt |
| 10 | + robots_path = os.path.join(base_dir, 'robots.txt') |
| 11 | + if os.path.exists(robots_path): |
| 12 | + with open(robots_path, 'r', encoding='utf-8') as f: |
| 13 | + report.write("--- robots.txt ---\n") |
| 14 | + report.write(f.read().strip() + "\n\n") |
| 15 | + else: |
| 16 | + report.write("--- robots.txt NOT FOUND ---\n\n") |
| 17 | + |
| 18 | + # Check sitemap.xml |
| 19 | + sitemap_path = os.path.join(base_dir, 'sitemap.xml') |
| 20 | + if os.path.exists(sitemap_path): |
| 21 | + with open(sitemap_path, 'r', encoding='utf-8') as f: |
| 22 | + lines = f.readlines() |
| 23 | + report.write("--- sitemap.xml (First 20 Lines) ---\n") |
| 24 | + report.write("".join(lines[:20]).strip() + "\n\n") |
| 25 | + else: |
| 26 | + report.write("--- sitemap.xml NOT FOUND ---\n\n") |
| 27 | + |
| 28 | + # Check meta tags and JSON-LD |
| 29 | + samples = [ |
| 30 | + 'index.html', |
| 31 | + 'posts/apple-macbook-pro-m4-pro-review.html', |
| 32 | + 'posts/lg-27us500-w-ultrafine-monitor-review.html', |
| 33 | + 'posts/surface-laptop-studio-2-review.html' |
| 34 | + ] |
| 35 | + |
| 36 | + report.write("--- Meta Title & Description Samples ---\n") |
| 37 | + for sample in samples: |
| 38 | + filepath = os.path.join(base_dir, sample) |
| 39 | + try: |
| 40 | + with open(filepath, 'r', encoding='utf-8') as f: |
| 41 | + content = f.read() |
| 42 | + |
| 43 | + title = re.search(r'<title>(.*?)</title>', content, re.IGNORECASE | re.DOTALL) |
| 44 | + title_text = title.group(1).strip() if title else "NO TITLE" |
| 45 | + |
| 46 | + desc = re.search(r'<meta\s+name=["\']description["\']\s+content=["\'](.*?)["\']', content, re.IGNORECASE | re.DOTALL) |
| 47 | + desc_text = desc.group(1).strip() if desc else "NO DESCRIPTION" |
| 48 | + |
| 49 | + report.write(f"\n{sample}:\nTitle: {title_text}\nDesc: {desc_text}\n") |
| 50 | + |
| 51 | + if sample.startswith('posts/'): |
| 52 | + schema = "YES" if '<script type="application/ld+json">' in content else "NO" |
| 53 | + report.write(f"Has JSON-LD Schema: {schema}\n") |
| 54 | + |
| 55 | + # Check affiliate links |
| 56 | + amazon_links = re.findall(r'<a[^>]+href=["\'][^"\']*amazon\.com[^"\']*["\'][^>]*>', content, re.IGNORECASE) |
| 57 | + has_sponsored = all('rel="sponsored"' in link or "rel='sponsored'" in link for link in amazon_links) if amazon_links else False |
| 58 | + sample_link = amazon_links[0] if amazon_links else "No Amazon links found" |
| 59 | + |
| 60 | + clean_sample = re.sub(r'\s+', ' ', sample_link).strip() |
| 61 | + |
| 62 | + report.write(f"Has Amazon Links: {'YES' if amazon_links else 'NO'}\n") |
| 63 | + report.write(f"All Amazon links use rel='sponsored': {'YES' if has_sponsored else 'NO'}\n") |
| 64 | + report.write(f"Sample Affiliate Link Tag: {clean_sample[:100]}...\n") |
| 65 | + |
| 66 | + except FileNotFoundError: |
| 67 | + report.write(f"\n{sample}: FILE NOT FOUND\n") |
| 68 | + |
| 69 | +if __name__ == '__main__': |
| 70 | + verify_seo() |
0 commit comments