首页 > 解决方案 > 我的代码(Python)试图从某些区域中选择一堆 CSS

问题描述

我的代码试图从某些区域中选择一堆 CSS,但是我似乎无法弄清楚要选择什么。我正在使用 Python、bs4、requests 和 pandas。这就是我的代码是 atm。

from bs4 import BeautifulSoup
import requests as re

import pandas as pd

url = 'https://forum.sa-mp.com/search.php?searchid=22924663'

response = re.get(url)
soup = BeautifulSoup(response.content, "lxml")

body = soup.select_one('#inlinemodform > .alt1').text

with open('always.txt', 'w') as f:
    f.write(body + "\n")

print(body)

这就是我要选择的。 链接到图片

该网页的链接是https://forum.sa-mp.com/search.php?searchid=22924663以防您还没有想到。我怀疑您是否能够在不创建帐户的情况下访问它。希望你能帮忙!

标签: pythonpython-3.xbeautifulsouppython-requests

解决方案


推荐阅读