This TikTok Ads Scraper is designed to efficiently gather advertisements information from TikTok, utilizing Selenium for web scraping and BeautifulSoup for parsing the scraped HTML data. It captures various details such as ad ID, advertiser information, first and last shown dates, unique user views, target audience demographics, and more.
This dataset specifically captures advertisements related to the keyword "fashion" within the UK over the past 7 days. Access the dataset here.
https://colab.research.google.com/drive/1y4CYFRUGo_OVbwFcb86oH7nlBTDSfL43?usp=sharing
- Selenium WebDriver: Automates web browser interaction to scrape dynamic content.
- BeautifulSoup: Parses HTML content to extract ad details.
- Asyncio: Manages asynchronous tasks for improved performance.
- Apify SDK Integration: Stores and manages scraped data on the Apify platform.
- Python 3.6+
- Selenium
- BeautifulSoup4
- Apify Python Client
- A WebDriver (e.g., ChromeDriver) compatible with your browser version
-
Clone the Repository:
git clone https://github.com/your-username/tiktok-ads-scraper.git cd tiktok-ads-scraper
-
Install Dependencies:
pip install -r requirements.txt
-
WebDriver Setup:
- Download the WebDriver for your browser (e.g., ChromeDriver for Google Chrome) and place it in a known directory.
- Ensure the path to the WebDriver is correctly set in the script or added to your system's PATH variable.
-
Apify Setup:
- Create an account on Apify and obtain your API token.
- Update the
actor.json
file with your project details and Apify token.
Update the input_schema.json
with the start URLs and any other parameters you wish to customize for scraping. Then, run the scraper using:
python main.py
Scraped data is stored in the Apify dataset and can be accessed through the Apify platform. You can configure the output format (e.g., JSON, CSV) in the actor.json
file.
Contributions to improve the TikTok Ads Scraper are welcome. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.