Android client for CQU news
Windows 10 Server: Python3.7 + Django 3.0.4 Server Service: Pythonanywhere Client: SDK29
- Client:
'com.android.support:design:28.0.0' --for tabLayout 'com.android.support:viewpager:28.0.0' --for viewPager Baidu translation API(don't have to install yourself)
- Server packages:
requests 2.23.0 django 3.0.4 lxml 4.5.0 mysqlclient 1.4.6
You can just download the apk we provided for you. Without expectations, it should work well like this:
Of course you can test the application directly, but I'm suggesting you using a local server to host, mine is hosted on pythonanywhere
, it's a little slow when booted or updated.
- Client folder:
CQUnews-android
- Server folders:
-newsList ---index ---newsList -manage.py -virtualEnv
You can deploy on your server or a local one, when you do this, please do as following:
- Gather the server folders in your IDE
- Prepare your mysql database on your server or on your computer, you should create a database named 'newsdb'.
- Before running the server, you have to modify some codes:
- Enter the
VirtualEnv/Scripts
to activate the virtual environment. - Get into the folder(
newsList
) withmanage.py
inside it, usepython manage.py make migrations
,python manage.py migrate
in your terminal - Create superuser to avoid fill in the username and password all the time with
python manage.py createsuperuser
(this has to be the same in your settings.py/DATABASE) - Run
python runserver 0.0.0.0:8780(or other port) --noreload
in terminal - Then you can visit
http://localhost:8780/spider
to start crawling news from Cqu news website.(I haven't made it automatically, so you have to open the page yourself, when you see 'everything is ok', you can check your database now)
- You can install the .apk file in your phone or emulator, or build
CQUnews-android
in your IDE - If you deploy the server yourself, you can modify some codes to test your server:
NewsHttpUtil.java
--public static JSONArray reqNews
, modify thebaseUrl
to your server IP, or if you are using a local server, change it to your emulator/phone IP (use ipconfig, not the localhost or 127.0.0.1) for local server: for remote server:
Done:
- pull the news from CQU news website: http://news.cqu.edu.cn/newsv2/
- classify news in application
- update news manually System.out.println("init done");
- translate between Chinese and English(the call of Baidu Translation API is limited with free users, both the speed and amount, so I'm not sure whether this function will be kept in future.)
To do:
- transfer the project on another server, it's using 'pythonanywhere' right now, but I found that the platform doesn't support crawling, so I'm manually changing the cloud database right now.
- fix the bug (some fragments mix up) when updating news
- automatically update every day
If you have trouble with the App, click 'update' in the menu on the right top corner,or just restart it.
Welcome to give me your feedback here or email me at 13833799573@163.com