You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
791 B
37 lines
791 B
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
# 目标网站的URL
|
|
url = "https://m.xingming.com/dafen/"
|
|
|
|
# 准备要发送的数据,通常为字典格式
|
|
data = {
|
|
'xs': '黄',
|
|
'mz': '海',
|
|
'action': 'test'
|
|
}
|
|
|
|
# 发送POST请求
|
|
response = requests.post(url, data=data)
|
|
|
|
# 检查请求是否成功
|
|
if response.status_code == 200:
|
|
# print("请求成功。")
|
|
pass
|
|
else:
|
|
print("请求失败,状态码:", response.status_code)
|
|
|
|
# 打印响应内容
|
|
soup = BeautifulSoup(response.text, "html.parser")
|
|
|
|
# for i in range(4, 35):
|
|
# elements = soup.select("p")[i]
|
|
# print(elements)
|
|
|
|
|
|
# 得分
|
|
print(soup.select("p")[34].select("font")[0].text)
|
|
|
|
# 综合评价
|
|
print(soup.select("p")[34].select("font")[0].next.next.text[2:])
|