This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
101 lines (87 loc) · 3.19 KB
/
test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import webshrinker
access_key = "your-API-access-key"
secret_key = "your-API-secret-key"
url = "https://www.webshrinker.com"
###################################
# Thumbnail / Screenshot examples #
###################################
ws = webshrinker.Thumbnails(access_key, secret_key)
ws.debug = True
# this will return information about the thumbnail image for the URL: https://www.webshrinker.com
try:
print "Running ws.image() ..."
response = ws.image(url, size="xlarge")
# the response variable contains the PNG image data
except webshrinker.RequestException as e:
# an error happened while making the request (possible DNS or connection timeout issue)
raise
except webshrinker.ResponseException as e:
# a general error happened while receiving the response
raise
except webshrinker.UnauthorizedException as e:
# the API access or secret key used is invalid
raise
except webshrinker.RequestLimitException as e:
# the account reached its request limit
raise
print "\n"
# this will return information about the thumbnail image for the URL: https://www.webshrinker.com
try:
print "Running ws.info() ..."
response = ws.info(url)
print response
except webshrinker.RequestException as e:
# an error happened while making the request (possible DNS or connection timeout issue)
raise
except webshrinker.ResponseException as e:
# a general error happened while receiving the response
raise
except webshrinker.UnauthorizedException as e:
# the API access or secret key used is invalid
raise
except webshrinker.RequestLimitException as e:
# the account reached its request limit
raise
print "\n"
####################################
# Website Category Lookup examples #
####################################
ws = webshrinker.Categories(access_key, secret_key)
ws.debug = True
# this will list all the possible categories a website, URL, or IP address can be in
try:
print "Running ws.list() ..."
response = ws.list()
print response
except webshrinker.RequestException as e:
# an error happened while making the request (possible DNS or connection timeout issue)
raise
except webshrinker.ResponseException as e:
# a general error happened while receiving the response
raise
except webshrinker.UnauthorizedException as e:
# the API access or secret key used is invalid
raise
except webshrinker.RequestLimitException as e:
# the account reached its request limit
raise
print "\n"
# this will lookup the categories for the URL: https://www.webshrinker.com
try:
print "Running ws.lookup() ..."
response = ws.lookup(url)
print response
if response["categorizing"] == True:
print "** The URL is still being categorized, check back again soon **"
except webshrinker.RequestException as e:
# an error happened while making the request (possible DNS or connection timeout issue)
raise
except webshrinker.ResponseException as e:
# a general error happened while receiving the response
raise
except webshrinker.UnauthorizedException as e:
# the API access or secret key used is invalid
raise
except webshrinker.RequestLimitException as e:
# the account reached its request limit
raise