Skip to content

Conversation

@handysome6
Copy link

  • Create xhs_url_crawler.py with all necessary components
  • Include authentication (QR code and cookie login)
  • Support URL parsing and note detail fetching
  • Remove all database dependencies
  • Add comprehensive documentation in XHS_CRAWLER_README.md

Features:

  • Simple API for crawling individual Xiaohongshu notes
  • Multiple auth methods (QR code, cookies)
  • Automatic signature generation
  • Fallback to HTML parsing if API fails
  • Proxy support
  • No external dependencies on project structure

- Create xhs_url_crawler.py with all necessary components
- Include authentication (QR code and cookie login)
- Support URL parsing and note detail fetching
- Remove all database dependencies
- Add comprehensive documentation in XHS_CRAWLER_README.md

Features:
- Simple API for crawling individual Xiaohongshu notes
- Multiple auth methods (QR code, cookies)
- Automatic signature generation
- Fallback to HTML parsing if API fails
- Proxy support
- No external dependencies on project structure
Integrated the cookie persistence improvements from the other agent's work
into the standalone xhs_url_crawler.py module.

## Key Improvements

1. **CookieManager Class**
   - Save cookies to JSON file with timestamp
   - Load cookies from file
   - Validate cookie age (warns if >30 days old)
   - Clear and get cookie info methods

2. **Enhanced Login Flow**
   - Auto-save cookies after successful QR code login
   - Auto-load cookies from file if no cookie_str provided
   - All cookies are saved, not just web_session
   - New auto_login() method for seamless re-authentication

3. **XhsUrlCrawler Updates**
   - Added auto_save_cookies parameter (default: True)
   - Added cookie_dir parameter for custom cookie location
   - Initialize CookieManager in constructor
   - Pass cookie_manager to login objects

4. **Updated Documentation**
   - New "Cookie Management" section in README
   - Updated examples to show auto-login workflow
   - Added troubleshooting for auto-login issues
   - Added changelog showing v2.0 improvements

## Benefits

**Before**: Scan QR code every single run ❌
**After**: Scan QR code only once, then automatic authentication ✅

## Security

- Added cookies/ to .gitignore
- Cookie files stored locally with metadata
- No sensitive data committed to repository

This integration provides a much better user experience by eliminating
repeated QR code authentication while maintaining security.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants