2017-05-08 39 views
0

我是新来的履带,我不知道如何从https://www.autorentals.com得到的价格数据使用请求不能履带式https://www.autorentals.com

import requests 
url = 'https://www.autorentals.com/' 
data = { 
    'l': "LAX", 
    'date1': "05/14/2017", 
    'date2': "05/17/2017", 
    'time1': "10:00", 
    'time2': "10:00", 
    'type':"checkbox", 
} 

html_post = requests.post(url, data=data) 
print(html_post.content) 

返回的内容是不我点击查找优惠时想要获得的价格数据。

+0

html_post.content是完整的HTML。 你需要从html获得哪部分内容。 –

+0

感谢您的回复,我的邮政方式无法给我价格数据,我需要在搜索租车时获得价格,谢谢 –

回答

0

您将整个HTML作为文本接收。 里面,你必须总是有些部分定义的值你正在寻找:

<div class="rateCellDiv" id="matrixRate182809314"> 


          <a href="#" onclick="window.open('https://www.autorentals.com/reserve?rid=182809314&place=matrix_2');return false;" style="display: block;text-decoration: none;overflow: hidden;" class="arInternalLink"> 


         <span class="unitPrice"> 
          <span>$34.78</span> 
          <span style="color: #666666; font-size: 60%;font-weight: normal;">/ Day</span> 
         </span> 
         <span class="totalPrice" style="color: #666666;"> 
          total 
          $155.56 
         </span> 

          </a> 

      </div> 

所以,你可以简单地查看使用find法的东西来检查

"<span class="unitPrice"> 
          <span>" 

然后您搜索结束标签,你有你想要的价值。

+0

感谢您的回复,您如何得到价格,我没有得到它,是你使用与我的相同的邮政编码吗?谢谢 –