Skip to content

Commit c004127

Browse files
committed
Add a try Catch Exception for Unicode statement
1 parent 7b0eb22 commit c004127

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

api/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ def fetch_fromIT(url, schema, total):
7777
soup = BeautifulSoup(data, 'html.parser')
7878
result = ""
7979
for link in soup.find_all(schema.split(',')[0]):
80-
result += link.get(schema.split(',')[1])
81-
print(link.get(schema.split(',')[1]))
80+
try:
81+
result += link.get(schema.split(',')[1])
82+
print(link.get(schema.split(',')[1]))
83+
except:
84+
print "Error on coercing to Unicode: need string or buffer, NoneType found"
8285
return result
8386

8487
def getWebSite_and_schema_and_save_data():

0 commit comments

Comments
 (0)