【发布时间】:2021-07-29 12:36:20
【问题描述】:
from bs4 import BeautifulSoup
import requests
import re
username = input('enter username: ')
url = f'https://www.tiktok.com/@{username}'
response = requests.get(url).text
soup = BeautifulSoup(response, 'html.parser')
subname = soup.find('h1', class_="share-sub-title")
print(subname)
不管我搜索什么,它只返回“无”。请帮助我,过去 3 天我一直在寻找这个解决方案,但我找不到它。我也是编码新手,所以我很抱歉。
【问题讨论】:
-
尝试打印响应并验证您是否确实得到了预期的响应。
-
事实上你在
response中什么也得不到,只是一个空字符串。尝试使用selenium
标签: python web-scraping beautifulsoup python-requests