Skip to content

Commit 4909f0c

Browse files
committed
Create qimai_data.py
1 parent daa5e3f commit 4909f0c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ tweepy
2222
# yulewalker # uncomment once audio_filters/equal_loudness_filter.py is fixed
2323
typing_extensions
2424
xgboost
25+
DrissionPage ; python_version > '4.0.4.12'

web_programming/qimai_data.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""
2-
Qimai Data (qimai.cn) is a mobile product intelligence and business analysis platform in China.
2+
Qimai Data (qimai.cn) is a mobile product business analysis platform in China.
33
44
Get a dict of the app information for a given typename (free, paid, grossing) from https://www.qimai.cn
55
6-
DrissionPage is a simple encapsulation of the selenium package, which is continuously updated, and some of the code could be
7-
not compatible with the latest version of DrissionPage.
8-
96
p.s. Current version of DrissionPage : 4.0.4.17
7+
https://github.com/g1879/DrissionPage
108
"""
119

1210
from DrissionPage import ChromiumPage
@@ -21,7 +19,7 @@ def login(page: ChromiumPage, username: str, password: str) -> bool:
2119
page.ele(".submit").click()
2220
print("Login successfully")
2321
return True
24-
except:
22+
except KeyError:
2523
print("Login failed")
2624
page.close()
2725
return False
@@ -30,7 +28,8 @@ def login(page: ChromiumPage, username: str, password: str) -> bool:
3028
return True
3129

3230

33-
def get_app_info(page: ChromiumPage, username: str, password: str, typename: str) -> dict:
31+
def get_app_info(page: ChromiumPage,
32+
username: str, password: str, typename: str) -> dict:
3433
# Clear the cache to avoid the login failure
3534
page.clear_cache(cookies=True)
3635
if login(page, username, password):
@@ -82,11 +81,10 @@ def get_app_info(page: ChromiumPage, username: str, password: str, typename: str
8281
}
8382

8483
else:
85-
dic = {"error": "Login failed"}
84+
return {'error': 'Login failed'}
8685

8786
return dic
8887

89-
9088
if __name__ == "__main__":
9189
page = ChromiumPage()
9290
print(get_app_info(page, "YOUR USERNAME", "YOUR PASSWORD", "free"))

0 commit comments

Comments
 (0)