vicuna-33b· LMSYS
Arena Human Preference 55K
make script for a tiktok scrapper in a .bat file
- User
make script for a tiktok scrapper in a .bat file
- Assistant
Creating a .bat file for a TikTok scraper requires you to manually download a Python script and execute it. You can create a simple .bat file with the following steps:
- Open a text editor (e.g., Notepad) and save a new file with the extension
.bat. - In the
.batfile, paste the following Python code:
import os import time import requests from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import TimeoutException from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-extensions') chrome_options.add_argument('--disable-infobars') chrome_options.add_argument('--proxy-server=state.smartproxy.com:20000') driver = webdriver.Chrome(executable_path='D:\\Utilities\\chromedriver_win32\\chromedriver.exe', options=chrome_options) def get_tiktok_videos(): driver.get('https://www.tiktok.com/@username') time.sleep(3) profile_button = driver.find_element(By.CSS_SELECTOR, '.sent-by-author.tm-rl[scale-x-333]') profile_button.click() time.sleep(3) videos = driver.find_elements(By.CSS_SELECTOR, '.playlist-card__video') video_lists = [] for video in videos: video_url = video.get_attribute('src') video_title = video.find_element(By.CSS_SELECTOR, '.playlist-card__video-header.t-16.w-16').text video_lists.append([video_url, video_title]) return video_lists if __name__ == '__main__': username = 'username' # Replace this with - Open a text editor (e.g., Notepad) and save a new file with the extension
- User
continue
- Assistant
the desired TikTok username video_lists = get_tiktok_videos()
for index, video in enumerate(video_lists): print(f"{index + 1}. {video[1]} - {video[0]}") time.sleep(2)
driver.quit() print("Scraping complete.")
Remember to replace `'username'` with the desired TikTok username you want to scrape. 1. Save the file with a `.bat` extension (e.g., `scrape_tiktok.bat`). 2. Double-click the `.bat` file to execute it. The script will run in the command prompt, and you'll see the scraped video information printed on the screen. Please note that TikTok may have measures in place to prevent scraping, and this script might not work as intended. Additionally, using automated tools to access or scrape TikTok may violate their terms of service. Use this information at your own risk.