-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51d23ed
commit c15ee33
Showing
8 changed files
with
78 additions
and
209 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='dputils', | ||
version='1.0.1', | ||
description='This library is utility library from digipodium', | ||
author='Team Digipodium, Zaid Kamil, AkulS1008', | ||
author_email='xaidmetamorphos@gmail.com', | ||
url='https://github.com/digipodium/dputils', | ||
packages=find_packages(), | ||
install_requires=[ | ||
'docx2txt>=0.8', | ||
'pdfminer.six>=20220524', | ||
'fpdf2>=2.5.4', | ||
'bs4>=0.0.1', | ||
'python-docx>=0.8.11', | ||
'httpx[http2]>=0.25.1', | ||
], | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Programming Language :: Python :: 3', | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
from dputils.scrape import Scraper, Tag | ||
|
||
class TestScrapeModule: | ||
@pytest.fixture | ||
def scraper(self): | ||
url = "https://www.example.com" | ||
return Scraper(url) | ||
|
||
@pytest.fixture | ||
def title_tag(self): | ||
return Tag(name='h1', cls='title', output='text') | ||
|
||
@pytest.fixture | ||
def price_tag(self): | ||
return Tag(name='span', cls='price', output='text') | ||
|
||
def test_get_data_from_page(self, scraper, title_tag, price_tag): | ||
data = scraper.get_data_from_page(title=title_tag, price=price_tag) | ||
assert isinstance(data, dict) | ||
assert 'title' in data | ||
assert 'price' in data | ||
|
||
def test_get_repeating_data_from_page(self, scraper): | ||
target_tag = Tag(name='div', cls='product-list') | ||
item_tag = Tag(name='div', cls='product-item') | ||
title_tag = Tag(name='h2', cls='product-title', output='text') | ||
price_tag = Tag(name='span', cls='product-price', output='text') | ||
link_tag = Tag(name='a', cls='product-link', output='href') | ||
|
||
products = scraper.get_repeating_data_from_page( | ||
target=target_tag, | ||
items=item_tag, | ||
title=title_tag, | ||
price=price_tag, | ||
link=link_tag | ||
) | ||
|
||
assert isinstance(products, list) | ||
for product in products: | ||
assert isinstance(product, dict) | ||
assert 'title' in product | ||
assert 'price' in product | ||
assert 'link' in product |