File size: 893 Bytes
7ef4196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from abc import ABC, abstractmethod
import pandas as pd

class ParseWebsite(ABC):
    '''
    Abstract Class for parsing website
    '''

    @abstractmethod
    def get_table(html: str) -> pd.DataFrame:
        '''
        Args:
            html: string
        Returns:
            pd.DataFrame: Competition records
        '''
        pass


class ParseCraft(ParseWebsite):
    '''
    Parse craft.co website for competitor intel
    '''

    def get_table(self,html: str) -> pd.DataFrame:
        html_tables = pd.read_html(html, index_col=0)[0]
        return html_tables
    

class ParseLink:
    '''
    Parses Website
    '''
    def __init__(self,website_type: str,html: str):
        self.website_type = website_type
        self.html = html
    
    def parse(self):
        if(self.website_type == "craft"):
            df = ParseCraft().get_table(self.html)
            return df