-
Notifications
You must be signed in to change notification settings - Fork 4
/
check_url.py
executable file
·54 lines (42 loc) · 1.78 KB
/
check_url.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
"""
check_url.py
Standalone script to test the product page crawler.
Copyright (c) 2022 Kevin
This file is part of Argostimè.
Argostimè is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Argostimè is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Argostimè. If not, see <https://www.gnu.org/licenses/>.
"""
import sys
import traceback
from argostime.crawler.crawl_url import crawl_url
from argostime.crawler.crawl_utils import CrawlResult
# Print help message if needed...
if len(sys.argv) < 2 or len(sys.argv) > 2 or "help" in sys.argv[1]:
print(f"usage: {sys.argv[0]} url")
exit()
# Just call the crawler with the url given by the user
try:
result: CrawlResult = crawl_url(sys.argv[1])
except Exception as exception:
print("Exception thrown during crawling:", file=sys.stderr)
traceback.print_exc()
exit()
# Crawling was successful, print results...
print("Crawling result:")
print(f" -> URL: {result.url}")
print(f" -> Name: {result.product_name}")
print(f" -> Description: {result.product_description}")
print(f" -> Code: {result.product_code}")
print(f" -> Price: {result.normal_price}")
print(f" -> Discount: {result.discount_price}")
print(f" -> On-sale: {result.on_sale}")
print(f" -> EAN: {result.ean}")