forked from ecodomen/nsreg-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_speedhosting.txt
45 lines (34 loc) · 1.35 KB
/
example_speedhosting.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
import logging
import re
import scrapy
from nsreg.items import NsregItem
from ..utils import find_price
#работает
REGEX_PATTERN = r"([0-9]+[.,\s])?руб"
EMPTY_PRICE = {
'pricereg': None,
'price_prolong': None,
'price_change': None,
}
#Из nsreg_101domain
#https://www.speedhosting.ru
class Nsreg_ad100Spider(scrapy.Spider):
name = 'nsreg_speedhosting'
allowed_domains = ['speedhosting.ru']
start_urls = ['https://www.speedhosting.ru/site/tariffs']
def parse(self, response):
pricereg = response.xpath('/html/body/section/div/div/div/div[2]/div[1]/div[2]/span/text()').get()
pricereg = find_price(REGEX_PATTERN, pricereg)
price_prolong = response.xpath('/html/body/section/div/div/div/div[2]/div[2]/div[2]/span/text()').get()
price_prolong = find_price(REGEX_PATTERN, price_prolong)
price_change = response.xpath('/html/body/section/div/div/div/div[2]/div[3]/div[2]/span/text()').get()
price_change = find_price(REGEX_PATTERN, price_change)
item = NsregItem()
item['name'] = "ООО «Быстрый Хостинг»"
price = item.get('price', EMPTY_PRICE)
price['pricereg'] = pricereg
price['price_prolong'] = price_prolong
price['price_change'] = price_change
item['price'] = price
yield item