簡體   English   中英

AttributeError: 'NoneType' object 沒有屬性 'get' helpp

[英]AttributeError: 'NoneType' object has no attribute 'get' helpp

我需要鏈接到最新的用戶 tiktok 視頻。 它有效,但隨后停止工作

import bs4
import requests
from fake_useragent import UserAgent
from bs4 import BeautifulSoup

link = "https://www.tiktok.com/@dava_m?"
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 OPR/81.0.4196.61'}
full_usd_page = requests.get(link, headers=headers).text
soup = BeautifulSoup(full_usd_page, 'html.parser')
product_link = soup.find("a", class_="").get("href")
print(link)
product_link = soup.find("a", class_="").get("href")
AttributeError: 'NoneType' object has no attribute 'get'

它沒有返回,但一個小時前它起作用了。 請幫助獲取最新的視頻鏈接https://www.tiktok.com/@dava_m

這意味着soup.find("a", class_="") 正在返回一個非類型object。 嘗試在沒有 get 位的情況下自行運行它並檢查 output。 確保以下 output 不是 None。

湯.find("a", class_="")

function 可能找不到任何東西。

可能頁面是動態生成的,僅僅使用requests是不夠的。 但其他方法要復雜得多。 它們可能是seleniumscrapy-splash等。在 web 中搜索python scrape dynamic content/page

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM