当前位置:首页 > python

dp爬携程

admin2年前 (2024-12-01)python1381
# https://hotels.ctrip.com/hotels/list?starlist=5&highPrice=-1&barCurr=CNY&sort=1
from DrissionPage import ChromiumPage

dp = ChromiumPage()
url = 'https://hotels.ctrip.com/hotels/list?starlist=5&highPrice=-1&barCurr=CNY&sort=1'
# 先监听数据包
dp.listen.start('json/HotelSearch')
# 后打开网站
dp.get(url)
# 爬3页
for i in range(3):

    # 等待数据包加载
    resp = dp.listen.wait()
    # 获取响应数据内容
    data = resp.response.body
    # print(data)
    hotle_list = data['Response']['hotelList']['list']
    for hotel in hotle_list:
        print(hotel['base']['hotelName'])
    # 下滑页面到底部
    dp.scroll.to_bottom()


扫描二维码推送至手机访问。

版权声明:本文由匡民博客发布,如需转载请注明出处。

本文链接:https://kuangmin.top/post/27.html

分享给朋友:

“dp爬携程” 的相关文章

一道数学题

# 已知50个1998相乘的结果是a,a的各位数的和是b, b的各位数的和是c,c的各位数的和是d, # 求d的值 a = 1998 ** 50 print(a) str_a = str(a) b&nbs…

《Python入门100题》之第一题:三位组合

第一题:有1,2,3,4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?list1 = [1, 2, 3, 4] list2 = [] for a in list1:  &…

《Python入门100题》之第八题:成绩分类

题目:利用条件运算符的嵌套来完成此题:学习成绩 >=90 分的同学用 A 表示,60-89 分之间的用 B 表示,60 分以下的用 C 表示score = int(input('输入分数:')) if score >= …

函数练习题

计算列表…

列表的删除方法练习题

# 练习:list1 = [1,2,3,4,5,5,4,3,2,1,1,2,3,4,5] # 需求:使用 remove 删除所有的 5 list1 = [1, 2, 3, 4,…