【问题标题】:can not crawler https://www.autorentals.com using python requestes无法使用 python 请求抓取 https://www.autorentals.com
【发布时间】:2017-05-08 08:00:39
【问题描述】:

我是爬虫新手,我不知道如何使用请求从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)

返回的内容不是我点击查找交易时想要得到的价格数据。

【问题讨论】:

  • html_post.content 是完整的 HTML。您需要html中的哪一部分。
  • 感谢您的回复,我的post方法无法给我价格数据,我需要在搜索租车时获取价格,谢谢

标签: python web-crawler python-requests


【解决方案1】:

您会收到整个 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-method 来检查要检查的东西

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

然后你搜索 span 的结束标签,你就有了你想要的值。

【讨论】:

  • 谢谢你的回复,这个价格是怎么得到的,我没弄明白,你用的是和我一样的邮编吗?谢谢
猜你喜欢
  • 2015-06-24
  • 2021-12-27
  • 1970-01-01
  • 2021-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-04
  • 1970-01-01
相关资源
最近更新 更多