import requests
from bs4 import BeautifulSoup
from fake_useragent import UserAgent
def url_get(url,head):
res = requests.get(url, headers=head)
print(res.status_code)
html = res.text
return html
def html_get(html):
soup = BeautifulSoup(html, "html.parser")
return soup
def content_get(soup):
texts = soup.find_all(class_='item-text-body')
for text in texts:
print(text.text)
# text = text.find(class_='item-text-body').text
# print(text)
url = 'https://www.taptap.com/app/189346/review?order=default&page=1#review-list'
head = {"User-Agent": UserAgent().random}
html = url_get(url, head)
soup = html_get(html)
text = content_get(soup)
20200527-taptap评论爬取
最新推荐文章于 2025-02-03 23:58:28 发布