예제 #1
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(PYTHON_WEB_URL)

        # Getting data from soup
        data = []
        divs = soup.find_all('div', {'class': 'post-cont'})
        figs = soup.find_all('figure', {'class': 'well-img'})

        for div, figure in zip(divs, figs):
            title = div.find('a').text
            url = f"https://www.infoworld.com{div.find('a')['href']}"
            img = figure.find('img')['data-original']

            data.append((url, title, img))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[5][1],
                                               languages[1][1])

        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'python.html', context)

        context = {
            'data': data,
        }
        return render(self.request, 'python.html', context)
예제 #2
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(REAL_PYTHON_WEB_URL)

        # Getting data from soup
        data = []

        posts = soup.find_all('div', {'class': 'card border-0'})

        for post in posts:
            a_tags = post.find_all('a')[0]
            title = a_tags.find('img')['alt']
            img = a_tags.find('img')['src']
            url = f"https://realpython.com{a_tags['href']}"
            data.append((url, title, img))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[6][1],
                                               languages[1][1])

        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'real_python.html', context)

        context = {
            'data': data,
        }
        return render(self.request, 'real_python.html', context)
예제 #3
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(COMPUTER_WORLD_WEB_URL)

        # Getting data from soup
        data = []
        main_div = soup.find('div', {'class': 'left-side'})
        divs = main_div.find_all('div', {'class': 'row-item-icon'})

        for div in divs:
            img = div.find('img', {'class': 'img-fluid'})['src']
            url = f"https://www.computerworld.pl{div.find('a')['href']}"
            title = div.find('a')['href'].split(',')[0].split('/')[2].replace(
                '-', ' ')

            data.append((url, title, img))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[4][1],
                                               languages[0][1])

        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'computer_world_news.html', context)

        context = {
            'data': data,
        }
        return render(
            self.request,
            'computer_world_news.html',
            context,
        )
예제 #4
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(TOJUZBYLO_URL)

        # Getting data from soup
        data = []
        tds = soup.find_all('td', {'class': 'col-1 col-first'})

        for td in tds:
            title = (td.find('h2', {'class': 'tytul'}).text).split('\n')[1]
            img = td.find('img')['src']
            href = td.find_all('a')[1]['href']
            url = f"https://tojuzbylo.pl/{href}"
            data.append((url, title, img))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[2][1],
                                               languages[0][1])

        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'tojuzbylo.html', context)

        context = {
            'data': data,
        }
        return render(
            self.request,
            'tojuzbylo.html',
            context,
        )
예제 #5
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(ZWIAD_HISTORII_URL)

        # Getting data from soup
        data = []
        divs_1 = soup.find_all(
            "div", {"class": 'td_module_1 td_module_wrap td-animation-stack'})

        for div in divs_1:
            divs_2 = div.find_all('div', {'class': 'td-module-thumb'})
            for element in divs_2:
                title = element.find('a')['title']
                url = element.find('a')['href']
                img = element.find('img')['data-img-url']
                data.append((url, title, img))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[3][1],
                                               languages[0][1])

        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'archeology.html', context)

        context = {
            'data': data,
        }
        return render(self.request, 'archeology.html', context)
예제 #6
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(BGG_URL)

        # Getting data from soup
        data = []
        posts = soup.find_all("h3", {"class": 'post_title'})

        for post in posts:
            title = post.find('a').text
            url = f"https://boardgamegeek.com{post.find('a')['href']}"
            data.append((url, title))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[1][1],
                                               languages[1][1])

        # Check if data not empty
        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'bgg.html', context)

        context = {
            'data': data,
        }
        return render(
            self.request,
            'bgg.html',
            context,
        )
예제 #7
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(BENCHMARK_URL)

        # Getting data from soup
        data = []

        sections = soup.find_all('section')
        section_3 = sections[3]
        section_3_divs = section_3.find_all('div')

        for div in section_3_divs[1:2]:
            benchmark_li = div.find_all('li')
            for li in benchmark_li:
                title = (li.find('a').text).split('\t\t\t')[1].split('\n')[0]
                url = f"http://benchmark.pl{li.find('a')['href']}"
                data.append((url, title))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[0][0],
                                               languages[0][1])

        # Check if data not empty
        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'benchmark.html', context)

        context = {
            'data': data,
        }
        return render(self.request, 'benchmark.html', context)
예제 #8
0
    def get(self, *args, **kwargs):
        soup = parse_a_website(BUSHCRAFTABLE_URL)

        # Getting data from soup
        data = []

        post_headers = soup.find_all('h2', {'class': 'entry-title'})
        post_images = soup.find_all('div', {'class': 'post-image'})

        for header, image in zip(post_headers, post_images):
            url = header.find('a')['href']
            title = header.find('a').text
            img = image.find('img')['src']
            data.append((url, title, img))

        # Creating Article
        Article.check_if_article_already_exist(data, portals[7][1],
                                               languages[1][1])

        if len(data) == 0:
            context = {
                'data': [('#', 'No data to view. Contact with administrator.')]
            }
            return render(self.request, 'bushcraftable.html', context)

        context = {
            'data': data,
        }
        return render(self.request, 'bushcraftable.html', context)


# soup.find_all(lambda tag: tag.name == 'p' and 'et' in tag.text)

# https://www.livescience.com/news

# TODO: Widok statystyk. Obliczenie ilości artykułów i piechart na widoku statystycznym,

# TODO: Settingsy porownac do django projektu KWL/Inforshare i pozmieniać.

# detect language - https://pypi.org/project/langdetect/