18 Commits

Author SHA1 Message Date
Elendil 2703e6d174 refactor zookeeper config provider
Also use a more elegent way to exit in memory Nscrapy Crawl mode
2018-07-09 23:42:03 +08:00
Elendil 8d471c72b0 Fix some bugs in sample project and increase timeout limit to 10sec while Spider is getting data from Redis
The timeout should be configable in the future

Signed-off-by: Elendil <zy4182@sina.com>
2018-06-05 22:46:31 +08:00
Elendil 3622c13fea individual downloader shell will update its downloader status to Redis
This is for the purpose of web console displaying distributed downloader status in the new future
2018-05-31 23:42:04 +08:00
Elendil 2d7be4f77d enhence the RedisScheduler
RedisScheduler will now register all the proper method in its registedCallback set at first, no need to wait until the callback is actually called
2018-05-25 01:02:08 +08:00
Elendil 32a1bf82f1 make the call back as Async, and fix bugs for ItemLoader while we are calling callback function in async way 2018-05-24 00:20:23 +08:00
Elendil 20e0982e88 ItemLoader Bug fix,CssSelector enhencement, ItemPipeline added 2018-05-22 23:50:25 +08:00
Elendil 0e36fea14d Bug Fix of ItemLoader and Add a MongoDBPipeline as Pipeline sample
Intergrate with MongoDB with MongoDB pipeline to store the information captured by NScrapy is AWESOME!
far more easy then Scrapy
2018-05-17 22:31:44 +08:00
Elendil 4afa454ebb Add support for xPathSelector
HtmlAgilityPack does not support extract attr directly, made some enhencement to xPathSelector so it can now directly extract attribute of html element like this
/html/body/div/div/div/div/ul/li[i/b="企"]/div/div/h3/a@href
2018-05-16 01:32:47 +08:00
Elendil 2ed341c009 Add Distributed Support for Spider
Still need some investigate against that if the spider will crawl the same page while there are multiple spider running
2018-05-09 01:30:43 +08:00
Elendil a47b109a2e Distributed Downloader Version 0.1
A big step for NScrayp, it can now utilize multiple Downloaders
Downloaders are now distributed to different process/machine, the connection
between Downloader and Spider is based on Scheduler, the scheduler distribute
Downloader task to different Downloader through Redis MQ
Details can be configed in appsetting.json
NScrapy still support single process mode, as long as we specify the run mode to InMemory
2018-05-06 22:57:39 +08:00
Elendil 46cf06b664 Create DownloaderShell Project to make Downloader Distributeable
Make a wrap of Downloader named DownloaderShell, so that it can handle
request sent from Redis, which is actually pushed in to the specific Queue defined in appsetting.json

Not finished yet
2018-05-04 00:26:46 +08:00
Elendil ebc8a738ef Created the very first verion of ItemLoader
this ItemLoader is more like a draft version of ItemLoader
It can do basic mappings from selector to object by defining mappings between selector and object field
later on will add pre processor, post processor while getting values from response and setting values to object
besides make a factory method to get ItemLoader, since for a particular Type, its ItemLoader barely changes, no need to new a ItemLoader for a same type everytime
2018-05-01 23:43:38 +08:00
Elendil d36d75558e Add mechanism to Exit a Crawl of a Spider and a Test Case for it
By checking if there is anymore Pending Request/Response in Queue and Running Downloader
NScrapy.Crawl would exit if no more pending Request/Response/RunningDownloader

Also add test case for this mechanism
2018-05-01 21:38:42 +08:00
Elendil 290d150b14 Bug Fix and UrlFilter Added
Fix the HttpHeaderMiddleware bug
Added UrlFilter with MD5 enhenced
Improved the sample Spider "JobSpider" so that it can now crawl all the .net postions posted at liepin.com
2018-04-28 01:17:08 +08:00
Elendil d299ff60f3 Bug Fix and Log Function
Added log4net at the bottom of the project, in NScrapyContext
Enhenced the Response.CssSelector so that we can select element based on a set of selector
This is very userful when the web page have tiny different between each page
2018-04-26 01:44:14 +08:00
Elendil 941750c5dc * HttpHeaderMiddleware.cs: Add HttpUserAgentPool middleware
* Program.cs:
* appsetting.json:
* NScrapy.Infra.csproj:
* HttpUserAgentPoolMiddleware.cs:
2018-04-23 20:22:24 +08:00
Elendil 2d9542a252 Add advanced CssSelector
we can now use  ::attr(href) syntax to get values from html attribute
example:
SourceHTML:
<div class="job-info">
<h3 title="招聘销售总监">
	<a href="https://www.liepin.com/job/1913549323.shtml" data-promid="imscid=R000000075&amp;ckid=b6ab9f62c5abd657&amp;headckid=b6ab9f62c5abd657&amp;pageNo=0&amp;pageIdx0&amp;totalIdx=0&amp;sup=1&amp;d_pageSize=40&amp;siTag=aEPqOr56EDcL1HyFlajr3w%7EfA9rXquZc5IkJpXC-Ycixw&amp;d_headId=549281be67f4c28a83bd3d340965b270&amp;d_ckId=549281be67f4c28a83bd3d340965b270&amp;d_sfrom=search_fp&amp;d_curPage=0&amp;d_posi=0" target="_blank" onclick="tlog=window.tlog||[];tlog.push('c:w_sojob_jobclick_9')">
销售总监 </a>
</h3>
</div>

Selector:
Response.CssSelector(".job-info h3 a::attr(href)").Extract();
The above will get a IEnumerable<String> that only contains the href of the link in above SourceHTML
Response.CssSelector(".job-info h3 a::attr(href)").ExtractFirst();
The above code will get the first element as string from the CssSelector, here the value is
https://www.liepin.com/job/1913549323.shtml

::attr(text) will get the InnerText of the element
2018-04-20 01:23:44 +08:00
Elendil 4096ac1abf Framework setup 2018-04-09 01:03:14 +08:00