【问题标题】:Is it a correct way of doing loops to open urls in python在python中打开url是一种正确的循环方式吗
【发布时间】:2022-01-13 09:03:05
【问题描述】:
df = pd.read_excel("file.xlsx", sheet_name = "Sheet1")

cnt = 0
for i in range(0, len(df)):
  cnt += 1
  driver.get(df['urls'][0])

'df'在一列中包含4个url,标题为'urls',我想一个一个打开它们:

打开第一个网址
发表评论
关闭

打开第二个网址
发表评论
关闭

..迭代

我尝试了多种执行循环的方法,但都没有成功。

您能否提供一些提示来解决这个问题?

干杯!

【问题讨论】:

    标签: python excel loops for-loop


    【解决方案1】:

    您需要执行以下操作:

    for url in df["urls"]:
        driver.get(url)
        ### Do stuff here with webdriver
    

    这样你就可以遍历"urls"df 中的网址

    【讨论】:

      猜你喜欢
      • 2016-07-30
      • 1970-01-01
      • 2020-10-12
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多