2017-05-08 211 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

感謝您的回覆,您如何得到價格,我沒有得到它,是你使用與我的相同的郵政編碼嗎?謝謝 –