Scraplingで副業を自動化する方法【Python製スクレイピングの新定番・GitHubスター26,000+】

Uncategorized

副業で情報収集やデータ取得を自動化したいけど、BeautifulSoupは遅いしScrapyは難しい。そんなエンジニアに今週GitHubで急上昇しているScraplingが刺さる。

今週だけで6,700スター以上獲得。スター数は26,000超え。Scrapy風のAPIとCloudflareバイパスを備えた、副業自動化にうってつけのPythonスクレイピングフレームワークです。

この記事でわかること:

  • Scraplingとは何か(Scrapy・BeautifulSoupとの違い)
  • インストールから動かすまでの手順
  • 副業に使える実践的なユースケース
  • 大規模クローリングへの発展方法

Scraplingとは?

一言で言うと「Scrapyの使いやすさとBeautifulSoupのシンプルさを両立した、反ボット対策済みのスクレイピングフレームワーク」です。

GitHub: https://github.com/D4Vinci/Scrapling(スター26,000+)

従来ツールとの違い

| | BeautifulSoup | Scrapy | Scrapling |

|—|—|—|—|

| 学習コスト | 低い | 高い | 低〜中 |

| 速度 | 遅い | 速い | 速い |

| Cloudflare対応 | ✗ | △(プラグイン必要) | ✅ 標準搭載 |

| ブラウザ自動化 | ✗ | ✗ | ✅ Playwright連携 |

| 適応型解析 | ✗ | ✗ | ✅ |

| 副業向け | △ | △ | ✅ |

Scraplingの最大の特徴は反ボット対策を標準搭載している点。Cloudflare Turnstileを自動でバイパスできるので、多くのサイトでスクレイピングが通ります。


インストール

pip install scrapling

それだけ。依存関係も最小限で、環境構築に詰まることがほぼない。

ブラウザ自動化(Playwright連携)も使う場合:

pip install scrapling[playwright]
playwright install chromium

基本的な使い方

シンプルなHTTPリクエスト

from scrapling.fetchers import Fetcher

page = Fetcher.get('https://example.com')

titles = page.css('h2').getall()
print(titles)

prices = page.xpath('//span[@class="price"]/text()').getall()

Cloudflareサイトへのアクセス

from scrapling.fetchers import PlayWrightFetcher

page = PlayWrightFetcher.fetch('https://cloudflare-protected-site.com')
data = page.css('.content').get()

Spider(定期クローリング)

from scrapling.spiders import Spider

class PriceSpider(Spider):
    name = "price_monitor"
    start_urls = ["https://example.com/products"]

    async def parse(self, response):
        for item in response.css('.product'):
            yield {
                "name": item.css('.name::text').get(),
                "price": item.css('.price::text').get(),
            }
scrapling crawl price_spider.py

副業に使える実践ユースケース

ユースケース1: 競合価格モニタリング

クライアントから「競合サイトの価格を毎日チェックしてほしい」という依頼はよくある副業案件。

from scrapling.fetchers import Fetcher
import json
from datetime import datetime

def monitor_prices(urls: list[str]) -> list[dict]:
    results = []
    for url in urls:
        page = Fetcher.get(url)
        price = page.css('.price::text').get()
        results.append({
            "url": url,
            "price": price,
            "checked_at": datetime.now().isoformat()
        })
    return results

data = monitor_prices(["https://shop.example.com/item/1"])
with open("prices.json", "w") as f:
    json.dump(data, f, ensure_ascii=False, indent=2)

これをcronで毎日実行すれば、価格変動の監視ツールが完成。

ユースケース2: 求人情報の自動収集

技術系求人を自動収集してNotionやスプレッドシートに流す。副業探しの効率化にも使える。

from scrapling.spiders import Spider

class JobSpider(Spider):
    name = "jobs"
    start_urls = ["https://job-site.example.com/engineer"]

    async def parse(self, response):
        for job in response.css('.job-listing'):
            yield {
                "title": job.css('.job-title::text').get(),
                "company": job.css('.company::text').get(),
                "salary": job.css('.salary::text').get(),
                "url": job.css('a::attr(href)').get(),
            }

ユースケース3: ブログネタの自動収集

GitHubトレンドやHacker Newsをスクレイピングして、Notionのネタ帳に自動追加。

from scrapling.fetchers import Fetcher

page = Fetcher.get('https://github.com/trending')
repos = []
for repo in page.css('.Box-row'):
    name = repo.css('h2 a::text').getall()
    stars = repo.css('.octicon-star + span::text').get()
    desc = repo.css('p::text').get()
    repos.append({
        "name": " ".join(name).strip(),
        "stars_today": stars,
        "description": desc
    })

print(repos[:5])

VPSで動かして完全自動化

スクレイピングを24時間動かすにはVPSが必要。

ConoHa VPS 1GBプラン(月880円〜)でScraplingを常時稼働させれば、クライアント向けの自動データ収集サービスを低コストで運用できます。

VPS上でcronを設定してスクレイピングを定期実行:

0 9 * * * /usr/bin/python3 /home/user/price_monitor.py >> /var/log/scraping.log 2>&1

Scraplingが向いている人・向いていない人

向いている人:

  • Pythonで自動化副業を始めたい人
  • BeautifulSoupに速度の限界を感じている人
  • Cloudflareで弾かれて困っていた人
  • Scrapy は複雑すぎると思っていた人

向いていない人:

  • Pythonが初めての完全初心者
  • 軽量な静的サイトのスクレイピングだけをしたい人(requests + BeautifulSoupで十分)

まとめ

Scraplingは「Scrapyの本格機能をシンプルなAPIで使える」スクレイピングフレームワークです。Cloudflareバイパス・Playwright連携・適応型解析を標準搭載しており、副業でのデータ収集自動化に最適。

  • pip install scrapling だけで始められる
  • Cloudflare対応で詰まりにくい
  • Scrapy風のSpider APIで本格クローリングも可能

今週GitHubで+6,700スターを記録した勢いのあるOSS。副業の自動化ネタを探しているエンジニアはぜひ試してみてください。

  • GitHub: https://github.com/D4Vinci/Scrapling(スター26,000+)

関連記事(内部リンク候補):

  • GitHub Actions入門【副業エンジニアが使える自動化レシピ5選】
  • n8nをVPSでセルフホストする方法
  • エンジニア副業に使えるOSSツール10選

関連記事

コメント

タイトルとURLをコピーしました