Call class variable indice value upon instantiating

Question

Im rusty on classes, and thus I dont understand how to properly instantiate my own right now.

Here is the class Scrapse.py:

import scrapy

class Se(scrapy.Spider):

    def parse(self, seach_engine, site_to_parse, page_start, page_end, response):
        seach_engine = [
            'se1.com',
            'se2.com',
        ]

        site = str(seach_engine+site_to_parse)
        if site_to_parse == seach_engine[0]:
            print("executing against se1!")
        elif site_to_parse == searh_engine[1]:
            print("executing against se2!")
        else:
            print("Something bad happened.")

I've learned I can instantiate this class via terminal like

>>> from Scrapse import Se
>>> s = Se.parse()

The problem is, for the first param (technically the second) for search_engine i want to instantiate s var for the first indice value in search_engine for se1.com.

How can i do this?

Thanks


Show source
| class   | python   | instantiation   2017-01-07 23:01 0 Answers

Answers ( 0 )

◀ Go back