【问题标题】:changing site dropdown value with python使用python更改站点下拉值
【发布时间】:2014-01-08 03:24:20
【问题描述】:

我正在编码一个带有用户并通过的网站的小程序,然后在个人资料页面中,有一个带有电话号码的下拉列表,当一个数字列为数字时,页面重新加载带有不同的数据,我什么我正在尝试遍历下拉列表中的所有数字并保存每个页面中的一些信息。

到目前为止,我所得到的只是从 html 中获取信息,但我不知道所有数字是如何变化的。

    <form action="/me/plan" id="form-active-subscriber" method="get">
      <select class="span3" id="current_subscriber" name="current_subscriber">
          <option value="998473069" selected="selected">56951292575</option>
          <option value="998487400">56951231211</option>
          <option value="998473907">56951294007</option>
          <option value="998474581">56951242122</option>
          <option value="998474544">56951240563</option>
          <option value="998487484">56951232281</option>
          <option value="998474580">56951241415</option>
          <option value="998473188">56951286777</option>
    </form> 

选择值时,URL将更改为

    somthing.com/plan?utf8=✓&current_subscriber=998473907

顺便说一下,我正在使用 beautifulsoup 来解析 HTML

谢谢

【问题讨论】:

    标签: python html beautifulsoup urllib


    【解决方案1】:

    我很容易解决它

        html = response.read()
    
        soup = BeautifulSoup(html)
    
        numbers = soup.select("option")
    
        for number in numbers:
            number = number["value"]
            response = self.opener.open(page+"plan?utf8=&current_subscriber="+number, None, 10)  
    

    【讨论】:

      猜你喜欢
      • 2019-07-26
      • 2016-05-19
      • 2018-07-14
      • 2023-02-11
      • 2019-11-04
      • 2023-03-21
      • 2010-11-26
      • 1970-01-01
      • 2019-10-08
      相关资源
      最近更新 更多