Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
open default browser to query when no results find or errors happen
  • Loading branch information
LewisTian committed Feb 26, 2019
1 parent 15a3302 commit 131256b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hust-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Key Binding | Description
<kbd>Ctrl + ENTER</kbd> | 跳转

### LICENSE
Copyright (c) 2019 Lewis Tian. Licensed under the MIT license.
Copyright (c) 2019 Lewis Tian. Licensed under the GNU General Public License v3.0.
Binary file added hust-lib/src/library.ico
Binary file not shown.
11 changes: 7 additions & 4 deletions hust-lib/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ def books(self):
soup = Soup(r.text, 'html5lib')
table = soup.find('table', {'calss', 'browseScreen'})
pages = table.find('tr', {'class', 'browsePager'})
except Exception as e:
self.error.emit(e)
except:
self.error.emit('未找到该书的信息...')
return
if not pages:
QDesktopServices.openUrl(QUrl(f'http://ftp.lib.hust.edu.cn/search*chx/X?SEARCH={self.kw}'))
return
last_page = pages.find_all('a')[-2]
link = last_page['href']
Expand All @@ -193,8 +196,8 @@ def detail(self, link):
r = requests.get(url, headers = self.headers)
soup = Soup(r.text, 'html5lib')
info = soup.find_all('tr', {'calss', 'bibItemsEntry'})
except Exception as e:
self.error.emit(e)
except:
self.error.emit('未找到该书的信息...')
return
ret = '\n'.join([x.text.replace('\n', '') for x in info])
self.detail_done.emit(ret)
Expand Down

0 comments on commit 131256b

Please sign in to comment.