-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sardor
committed
Nov 28, 2014
1 parent
9413804
commit b369d29
Showing
8 changed files
with
37 additions
and
25 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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -8,4 +8,5 @@ | |
|
||
class UzbdictspiderPipeline(object): | ||
def process_item(self, item, spider): | ||
print item | ||
return item |
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
File renamed without changes.
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,32 @@ | ||
# -*- coding: utf-8 -*- | ||
import scrapy | ||
import string | ||
from uzbdict.items import DictionaryItem | ||
import html2text | ||
|
||
|
||
class UzbDictSpider(scrapy.Spider): | ||
name = "uzbdictspider" | ||
allowed_domains = ["www.uzbek-dictionary.com"] | ||
# start_urls = ( | ||
# 'http://www.uzbek-dictionary.com/trans.php?trans_text=e&trans_lang=uz_en&trans_number=10000', | ||
# ) | ||
|
||
def start_requests(self): | ||
start_urls = ['http://www.uzbek-dictionary.com/trans.php?trans_text=%s&trans_lang=uz_en&trans_number=10000' % i \ | ||
for i in string.lowercase] | ||
return [scrapy.Request(url=start_url) for start_url in start_urls] | ||
|
||
def parse(self, response): | ||
hxs = scrapy.Selector(response) | ||
item = DictionaryItem() | ||
letters = hxs.xpath('/html/body/div[@class="frame"]/a/text()').extract() | ||
separators = hxs.xpath('/html/body/div[@class="frame"]/span[@class="seperator"]/text()').extract() | ||
translations = hxs.xpath('/html/body/div[@class="frame"]/div[@class="meaning_wrapper"]').extract() | ||
# print len(letters), len(separators), len(translations) | ||
# print letters, len(letters) | ||
# print separators, len(separators) | ||
# print translations, len(translations) | ||
trans_items = [html2text.html2text(t).strip() for t in translations] | ||
dictionary = dict(zip(letters, trans_items)) | ||
print dictionary |
This file was deleted.
Oops, something went wrong.