我想从这个网页上删除数据

我想得到所有的博客...在结果标签(<div class="results">)

In browser tools there it is showing under result tag there are 10 snippets... enter image description here

但使用Beautifulsoap我得到了

<div class="results">
</div>

postman 也得到了同样的东西..

我就是这么做的..

topicuri = "https://search.donanimhaber.com/portal?q=vodafone&p=3&devicetype=browsermobile&order=date_desc&in=all&contenttype=all&wordtype=both&range=all"
r = s.get(topicuri)
soup = BeautifulSoup(r.text, 'html.parser')
pages = soup.find('div', {'class': 'results'})
print(pages)

推荐答案

您还可以从api调用json响应中获取数据

import requests
import json 
body= "vodafone"
headers= {
    'content-type': 'application/json'
   }

api_url = "https://search.donanimhaber.com/api/search/portal/?q=vodafone&p=3&devicetype=browsermobile&order=date_desc&in=all&contenttype=all&wordtype=both&daterange=all"

jsonData = requests.post(api_url, data=json.dumps(body), headers=headers).json()

for item in jsonData['contents']:
    categoryName=item['categoryName']
    print(categoryName)

输出:

Operatörler - Kurumsal Haberler
Operatörler - Kurumsal Haberler
Operatörler - Kurumsal Haberler
Mobil Aksesuarlar
Operatörler - Kurumsal Haberler
Kripto Para
Sinema ve Dizi
Mobil Oyunlar
Operatörler - Kurumsal Haberler
Operatörler - Kurumsal Haberler

Python相关问答推荐

数字梯度的意外值

Python中的函数中是否有充分的理由接受float而不接受int?

如何使用stride_tricks.as_strided逆转NumPy数组

Pandas 除以一列中出现的每个值

GL pygame无法让缓冲区与vertextPointer和colorPointer一起可靠地工作

如何使用Google Gemini API为单个提示生成多个响应?

Python多处理:当我在一个巨大的pandas数据框架上启动许多进程时,程序就会陷入困境

_repr_html_实现自定义__getattr_时未显示

如何使用数组的最小条目拆分数组

如何在solve()之后获得症状上的等式的值

SQLAlchemy Like ALL ORM analog

从spaCy的句子中提取日期

移动条情节旁边的半小提琴情节在海运

实现神经网络代码时的TypeError

将pandas导出到CSV数据,但在此之前,将日期按最小到最大排序

无论输入分辨率如何,稳定扩散管道始终输出512 * 512张图像

在pandas数据框中计算相对体积比指标,并添加指标值作为新列

处理Gekko的非最优解

如何过滤组s最大和最小行使用`transform`'

有没有办法在不先将文件写入内存的情况下做到这一点?