0
我使用scrapy抓取我拥有的旧网站,我将下面的代码用作我的蜘蛛。我不介意为每个网页输出文件,或者包含所有内容的数据库。但我确实需要能够有蜘蛛爬行用了我不得不把在我目前不得不做的每一个网址获取scrapy蜘蛛抓取整个网站
import scrapy
class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["www.example.com"]
start_urls = [
"http://www.example.com/contactus"
]
def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename, 'wb') as f:
f.write(response.body)
您可能想要将'follow = True'添加到该规则,以继续爬行链接。 –
是的,谢谢。 –