-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redditPost search, refactored spiders, crawl script
- Loading branch information
Showing
8 changed files
with
118 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
# Runs all crawlers | ||
|
||
echo 'Spinning up crawlers...' | ||
cd sleuth_crawler/scraper | ||
python crawl.py & read -t 10 ; kill $! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sys | ||
import os.path | ||
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) | ||
sys.path = sys.path + [os.path.join(PROJECT_ROOT, '../../..'), os.path.join(PROJECT_ROOT, '../..')] | ||
|
||
from scrapy.crawler import CrawlerProcess, CrawlerRunner | ||
from scrapy.utils.project import get_project_settings | ||
from sleuth_crawler.scraper.scraper.settings import CUSTOM_URLS | ||
from sleuth_crawler.scraper.scraper.spiders.parsers.course_parser import parse_subjects | ||
|
||
''' | ||
This script runs all our spiders. | ||
Crawl specific item types, such as CourseItem, before starting the broad_crawler | ||
''' | ||
|
||
def run(): | ||
process = CrawlerProcess(get_project_settings()) | ||
process.crawl('broad_crawler') | ||
process.crawl('custom_crawler', start_urls=CUSTOM_URLS['courseItem'], parser=parse_subjects) | ||
process.start() | ||
|
||
if __name__ == "__main__": | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import scrapy | ||
from scrapy.spiders import Spider | ||
|
||
class CustomCrawler(Spider): | ||
''' | ||
Spider that crawls specific domains for specific item types | ||
that don't link to genericItem | ||
''' | ||
name = 'custom_crawler' | ||
|
||
# Specifies the pipeline that handles data returned from the parsers | ||
custom_settings = { | ||
'ITEM_PIPELINES': { | ||
'scraper.pipelines.SolrPipeline': 400, | ||
} | ||
} | ||
|
||
def __init__(self, start_urls, parser): | ||
''' | ||
Takes a list of starting urls and a callback for each link visited | ||
''' | ||
self.start_urls = start_urls | ||
self.parse = parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters