scraping tutorial
- Python 100%
| __pycache__ | ||
| README.md | ||
| scrape_drama_cast_crew.py | ||
| scrape_drama_details.py | ||
| scrape_drama_recommendations.py | ||
| scrape_drama_reviews.py | ||
| scrape_drama_top_or_polular.py | ||
| scrape_track_user_by_year.py | ||
| scrape_user_drama_list.py | ||
| scrape_user_information.py | ||
| ultil.py | ||
PythonScraper - MyDramaList Scraping Toolkit
Giới thiệu
Bộ công cụ Python tự động thu thập thông tin phim, diễn viên, review, user... từ MyDramaList. Dữ liệu được lưu ra file .txt để dễ dàng tra cứu và phân tích.
Yêu cầu hệ thống
- Python 3.8 trở lên
- Hệ điều hành: Windows (khuyến nghị)
- Kết nối Internet
Cài đặt thư viện
Mở terminal tại thư mục dự án và chạy:
pip install cloudscraper beautifulsoup4 lxml
Cấu trúc thư mục
pythonscraper/
│
├── scrape_drama_top_or_polular.py # Lấy danh sách phim top/popular
├── scrape_drama_cast_crew.py # Lấy thông tin diễn viên, đạo diễn
├── scrape_drama_reviews.py # Lấy review của phim
├── scrape_drama_recommendations.py # Lấy phim được recommend
├── scrape_user_information.py # Lấy thông tin user MyDramaList
├── scrape_user_drama_list.py # Lấy danh sách phim của user (theo trạng thái)
├── scrape_track_user_by_year.py # Lấy thống kê user theo năm
├── ultil.py # Hàm tiện ích (load link, tạo scraper)
├── data/ # Thư mục lưu dữ liệu
└── ...
Hướng dẫn sử dụng
1. Lấy danh sách phim top/popular
Tạo file danh sách phim:
python scrape_drama_top_or_polular.py --type top
python scrape_drama_top_or_polular.py --type popular
File sẽ lưu tại
./data/list/top_dramas.txthoặcpopular_dramas.txt.
2. Lấy thông tin chi tiết phim
python scrape_drama_cast_crew.py --movie "Tên phim"
Tên phim phải khớp với tên trong
top_dramas.txt(không phân biệt hoa thường).
3. Lấy review của phim
python scrape_drama_reviews.py --movie "Tên phim"
4. Lấy phim được recommend
python scrape_drama_recommendations.py --name "Tên phim"
5. Lấy thông tin user
python scrape_user_information.py --link "https://mydramalist.com/profile/tenUser/"
6. Lấy danh sách phim của user (theo trạng thái)
python scrape_user_drama_list.py --link "https://mydramalist.com/profile/tenUser/" --status all
python scrape_user_drama_list.py --link "https://mydramalist.com/profile/tenUser/" --status completed
Các trạng thái gồm:
all,watching,completed,on_hold,dropped,plan_to_watch,undecided,not_interested.
7. Lấy thống kê user theo năm
python scrape_track_user_by_year.py --link "https://mydramalist.com/profile/tenUser/stats" --year 2023
Nếu không truyền --year, chương trình sẽ hiển thị danh sách các năm có thể lấy.
Lưu ý
- Nếu gặp lỗi không tìm thấy link phim, hãy chắc chắn đã chạy
scrape_drama_top_or_polular.pyđể tạo filetop_dramas.txt. - Một số chức năng có thể cần chỉnh sửa nhỏ tùy giao diện MyDramaList thay đổi.
- Dữ liệu sẽ được lưu vào các thư mục như
data/drama_cast_crew/,data/drama_reviews/,data/recommendations/,data/users/,data/list/.