Crawl iPhone listings using BeautifulSoup
Files
- crawl_iphones.py - main crawler script (requests + BeautifulSoup).
- shops_example.json - sample shop configurations. Update selectors to match the shop's HTML.
- requirements.txt - Python dependencies.
Usage
-
Create a virtual environment and install deps:
python -m venv .venv ..venv\Scripts\activate pip install -r requirements.txt
-
Edit
shops_example.jsonand add the real shop key with correcturlandselectors.urlcan include{page}which will be replaced by page numbers.selectorsmust includelistfor item container and optionaltitle,price,link,sellerCSS selectors.
-
Run:
python crawl_iphones.py example_shop --pages 2 --out iphones.json
Notes
- This simple crawler works for server-rendered pages. For JavaScript-heavy sites (Shopee, Lazada, Tiki) use Selenium or Playwright.
- Respect site robots.txt and terms of service. Add delays and caching to avoid overloading servers.