mirror of
https://github.com/xboxeer/NScrapy.git
synced 2026-10-29 04:17:45 +08:00
35 lines
888 B
C#
35 lines
888 B
C#
using NScrapy.Infra;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Text;
|
|
|
|
namespace NScrapy.Spider
|
|
{
|
|
public abstract class Spider:ISpider
|
|
{
|
|
public List<string> URLs { get; set; }
|
|
public List<ISpiderMiddleware> Middlewares { get ; set; }
|
|
|
|
public Spider()
|
|
{
|
|
NScrapyContext.CurrentContext.CurrentSpider = this;
|
|
}
|
|
|
|
public virtual void StartRequests()
|
|
{
|
|
foreach (var url in this.URLs)
|
|
{
|
|
HttpRequest request = new HttpRequest()
|
|
{
|
|
URL = url,
|
|
RequestSpider = this
|
|
};
|
|
NScrapyContext.CurrentContext.CurrentScheduler.SendRequestToReceiver(request);
|
|
}
|
|
}
|
|
|
|
public abstract void ResponseHandler(IResponse response);
|
|
}
|
|
}
|