Skip to content

Commit

Permalink
adjusted error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
iesus committed Jun 21, 2020
1 parent c7d3103 commit 19de490
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions _scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from bs4 import BeautifulSoup

G = nx.Graph()
cookies = {'JSESSIONID': input("COOKIE:")}
cookies = {'JSESSIONID': input("JSESSIONID:")}
hostList = {
'https://graph.api.smartthings.com',
'https://graph-na02-useast1.api.smartthings.com',
Expand All @@ -15,22 +15,23 @@

for host in hostList:
r = requests.get(host+'/device/list', cookies=cookies, allow_redirects=False)
print('Trying shard: ' + host)
if (r.status_code == 302):
print('Redirect deetected. Invalid login? Double check sessionID')
print('Redirect deetected. Invalid login? Double check JSESSIONID')
continue
if (r.status_code == 200):
print('Shard matching session found: '+ host)
break

if (r.status_code == 302):
print('Did not find any valid server, double check cookie')
print('Did not find any valid server, double check JSESSIONID')
exit()

soup = BeautifulSoup(r.content, "html.parser")
translationDict = {}

if (len(soup.select('#device-table > tbody > tr')) == 0):
print('No devices found')
print('No devices found, did you provide token to wrong shard?')
exit()

for device in soup.select('#device-table > tbody > tr'):
Expand Down

0 comments on commit 19de490

Please sign in to comment.