当前位置:首页 > python

dp爬携程

admin1年前 (2024-12-01)python1076
# 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爬携程” 的相关文章

dp爬起点中文网

from DrissionPage import WebPage page = WebPage() url = 'https://www.qidian.com/chapter/1036370336/74597756…

ddddocr的安装使用

pip install -i https://mirrors.bfsu.edu.cn/pypi/web/simple/  ddddocrfrom DrissionPage import ChromiumPage imp…

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

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

《Python入门100题》之第三题:整数排序

题目:输入三个整数x,y,z,请把这三个数由小到大输出.x = int(input('请输入第一个整数:')) y = int(input('请输入第二个整数:')) z = int(input('…

《Python入门100题》之第四题:统计字符个数

题目:输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数.# 题目:输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数. zimu = 0 kongge = 0 shuzi = 0 qita&n…

《Python入门100题》之第五题:计算阶乘的和

题目:求1+2!+3!+.....+20!的和.# 题目:求1+2!+3!+.....+20!的和. ji = 1 sum = 0 for i in range(1, 20 + 1):…