私はScrapyが初めてです。ここで私のスパイダーがtwistedwebをクロールします。
class TwistedWebSpider(BaseSpider):
name = "twistedweb3"
allowed_domains = ["twistedmatrix.com"]
start_urls = [
"http://twistedmatrix.com/documents/current/web/howto/",
]
rules = (
Rule(SgmlLinkExtractor(),
'parse',
follow=True,
),
)
def parse(self, response):
print response.url
filename = response.url.split("/")[-1]
filename = filename or "index.html"
open(filename, 'wb').write(response.body)
を実行する scrapy-ctl.py crawl twistedweb3
と、フェッチのみが行われました。
index.html
コンテンツを取得して、 を使用しSgmlLinkExtractor
てみました。期待どおりにリンクを抽出しますが、これらのリンクをたどることはできません。
どこが間違っているのか教えてもらえますか?
css、javascriptファイルを取得したいとします。どうすればこれを達成できますか? 完全なウェブサイトを取得するという意味ですか?