首页 > 解决方案 > Scrapy如何抓取tiktok中的视频链接

问题描述

我正在创建一个 tiktok 抓取项目,以获取任何用户 givin 的所有视频链接。

class Someclass:
    def parse(self, response):
        items = TiktokscrapyItem()
        full_name = response.css('h1.share-sub-title::text').extract()
        User_Name = response.css('.share-title::text').extract()
        verified_username = response.css('.verified::text').extract()
        Following = response.css('.number:nth-child(1) strong::text').extract()
        Followers = response.css('.number:nth-child(2) strong::text').extract()
        Likes = response.css('.number~ .number+ .number strong::text').extract()
        Bio = response.css('.mt10::text').extract()
        profile_img = response.css('.user-page-header img::attr(src)').extract()
        video_url = response.css('a[href*=tiktok.com]::attr(href)').extract()
        items['full_name'] = full_name
        items['User_Name'] = User_Name
        items['verified_username'] = verified_username
        items['Following'] = Following
        items['Followers'] = Followers
        items['Likes'] = Likes
        items['Bio'] = Bio
        items['profile_img'] = profile_img
        items['video_url'] = video_url
        yield items

现在一切正常,但视频网址!我已经尝试了很多方法,并弄明白了。谁能指出我的方向?

谢谢

标签: pythonscrapy

解决方案


推荐阅读