Commit 114200cd authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk Committed by Andrii Marynets

fis spider

parent e42ea2c0
......@@ -25,7 +25,7 @@ SECRET_KEY = '*%!eg7znv=2z5cak1fjt#6-org#i@pe%uy7vkks$&3otoupb8x'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*']
# Application definition
......
......@@ -99,6 +99,11 @@ ITEM_PIPELINES = {
DB = {
'host': 'localhost',
'user': 'root',
'pwd': 'andrew',
'pwd': 'Q!W@q1w2mysql',
'database': 'esi'
}
try:
from .local_settings import *
except ImportError:
pass
\ No newline at end of file
......@@ -9,19 +9,22 @@ from ..items import ExaItem
db_settings = get_project_settings().get('DB')
db = Database(**db_settings)
comp = db.select("SELECT id, name, country FROM wp_esi_entity WHERE id = 3;")
class MobiHealthNewsSpider(scrapy.Spider):
name = "mobihealthnews"
allowed_domains = ["www.mobihealthnews.com"]
def __init__(self):
self.news = list()
def __init__(self, *args, **kwargs):
self.condition = kwargs.get('query')
self.query = "SELECT id, name, country FROM wp_esi_entity WHERE 1 and id=3"
if self.condition:
self.query += ' and {}'.format(self.condition)
self.comp = db.select(self.query)
super(MobiHealthNewsSpider, self).__init__()
def start_requests(self):
companies = CompanyMaker(comp)
companies = CompanyMaker(self.comp)
companies.make_companies()
for i in companies.get_companies():
yield scrapy.Request(i.url, callback=self.parse, meta={'company': i,
......
......@@ -2,5 +2,4 @@ Scrapy==1.3.3
selenium==3.4.1
dateparser==0.6.0
Django==1.11.1
mysqlclient==1.3.4
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment