+
97
-

如果用python爬取下载淘宝商品链接内的视频和图片?

如果用python爬取下载淘宝商品链接内的视频和图片?

网友回复

+
19
-

使用selenium

pip install requests beautifulsoup4 selenium

具体参考代码

import requests
from bs4 import BeautifulSoup
from selenium import webdriver
import time
import os

def download_file(url, folder, filename):
    response = requests.get(url)
    if response.status_code == 200:
        with open(os.path.join(folder, filename), 'wb') as f:
            f.write(response.content)

def scrape_taobao_product(url):
    # 使用Selenium来加载动态内容
    driver = webdriver.Chrome()  # 需要下载ChromeDriver并设置路径
    driver.get(url)
 ...

点击查看剩余70%

我知道答案,我要回答