Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions 19 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# maven
chatbotv1/target/

# py
__pycache__/
*.pyc

# vim
*.swp
*.swo

# idea
*.iml
*.ipr
*.iws
.idea/

# tmp files
subtitle/subtitle_crawler/result/
16 changes: 16 additions & 0 deletions 16 subtitle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 爬取字幕语料

* 依赖curl
* 不支持 Windows
* Tested with py2.7

## Install
```
pip install scrapy
```

## Download Data
```
cd ChatBotCourse/subtitle/subtitle_crawler
scrapy crawl subtitle
```
Binary file removed BIN -172 Bytes subtitle/subtitle_crawler/__init__.pyc
Binary file not shown.
Binary file removed BIN -396 Bytes subtitle/subtitle_crawler/items.pyc
Binary file not shown.
13 changes: 8 additions & 5 deletions 13 subtitle/subtitle_crawler/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import os
from subprocess import call

DOWNLOAD_CMD = os.path.join(os.path.dirname(
os.path.realpath(__file__)), 'save.sh')

class SubtitleCrawlerPipeline(object):
'''
Download Subtitle with curl
'''
def process_item(self, item, spider):
url = item['url']
file_name = url.replace('/','_').replace(':','_')
fp = open('result/'+file_name, 'w')
fp.write(item['body'])
fp.close()
call([DOWNLOAD_CMD, url])
return item

Binary file removed BIN -835 Bytes subtitle/subtitle_crawler/pipelines.pyc
Binary file not shown.
19 changes: 19 additions & 0 deletions 19 subtitle/subtitle_crawler/save.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash
###########################################
# Save file with CURL
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
SAVE_PATH=$baseDir/result
# functions

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
if [ ! -d "$SAVE_PATH" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
mkdir -p $SAVE_PATH
fi

cd $SAVE_PATH
curl -JLO $1
Binary file removed BIN -723 Bytes subtitle/subtitle_crawler/settings.pyc
Binary file not shown.
Binary file removed BIN -180 Bytes subtitle/subtitle_crawler/spiders/__init__.pyc
Binary file not shown.
Binary file not shown.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.