找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 860|回复: 1

[求助] for循环第二次的时候为什么不执行了呀

1

主题

2

帖子

2

积分

贫民

积分
2
zzw6196015 发表于 2023-4-4 17:01:06 | 显示全部楼层 |阅读模式
from selenium import webdriver
browser = webdriver.Chrome()
for i in range(25):
    browser.get('https://staahmax.staah.net/be/indexpackdetail?m_currency=PHP&display=firm&propertyId=NDkxMA%3D%3D&checkIn='+str(i+4)+'-04-2023&checkOut='+str(i+5)+'-04-2023&display=firm&promoCode=&submit=Search&currency=PHP')
    test_class = browser.find_elements_by_css_selector("[class='packagesHeading packagesTop10 roomtypetitle col-md-8 col-sm-9 col-xs-12 padding0']")
    # print(test_class.text)
    # 遍历会出错,  不遍历只能得到第一个结果.     element加上s 返回的是集合. 不加s返回的text
    print("查询日期为"+str(i+4))
    for t in test_class:
        print("日期为"+str(i+4)+t.text)
browser.quit()
[size=13.0667px]查询日期为4日期为4Mithi Superior Room日期为4Mithi Deluxe Villa日期为4Mithi Seaview Villa查询日期为5查询日期为6查询日期为7

请问大家一下,  为什么第二个FOR循环 只执行一次呀 !

回复

使用道具 举报

1

主题

2

帖子

2

积分

贫民

积分
2
zzw6196015  楼主| 发表于 2023-4-4 17:12:08 | 显示全部楼层

查询日期为4
日期为4Mithi Superior Room
日期为4Mithi Deluxe Villa
日期为4Mithi Seaview Villa
查询日期为5
查询日期为6
查询日期为7
执行后返回的结果 5 6 7 没有执行到第二个for里面去
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表