32 lines
903 B
Python
32 lines
903 B
Python
import requests
|
|
from bs4 import BeautifulSoup as bs
|
|
import json
|
|
|
|
url = 'https://exam.detr.top/exam-b/movies'
|
|
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
|
'Referer': 'https://www.example.com'}
|
|
req = requests.get(url, headers=headers)
|
|
req.encoding="utf-8"
|
|
|
|
data=[]
|
|
|
|
soup=bs(req.text,"html.parser")
|
|
# print(soup)
|
|
|
|
# items=soup.find_all("div",class_="item")
|
|
# for i in range(len(items)):
|
|
# rank=i+1
|
|
# title=items[i].find("span",class_="title").get_text()
|
|
# actors=items[i].find("div",class_="bd").get_text().strip()
|
|
# try:
|
|
# actors=actors.split("主演:")[1].split("\n")[0]
|
|
# except:
|
|
# actors="无"
|
|
# quote=items[i].find("p",class_="quote").get_text().strip()
|
|
|
|
# data.append({
|
|
# "rank":rank,
|
|
# "title":title,
|
|
# "actors":actors,
|
|
# "quote":quote
|
|
# }) |