使用 Python 在 1 个页面上发布 2 个表单(Webscraping)

Posting 2 forms on 1 page with Python (Webscraping)

我正在尝试为我的客户构建一个网络爬虫,它将获得 www.wozwaardeloket.nl 上显示的当前价格。在第一部分中,我 post 接受数据表单并使页面接受 'cookie alert'。

在第二个请求中我想post把'Streetname + Number + City'的值改成同一页上的第二个post。我对 Python 还没有经验,所以也许有人可以告诉我我做错了什么?

import requests

url = 'https://www.wozwaardeloket.nl/' eerste_form = {'accept': 'true', 'akkoord': 'Verder'} nieuw_keywoord = {'searchInput': name, 'searchVal' : "Watermolen 21 Edam" }

x = requests.post(url, data = eerste_form) r = requests.post(x, data = nieuw_keywoord) #print the response text (the content of the requested file):

print(x.text)

我正在尝试提出另一个 post 请求,但显然它不是那样工作的,一直在尝试搜索互联网,但到目前为止没有很好的结果来解释它。

您可以直接向他们API提出请求:
https://www.wozwaardeloket.nl/api/geocoder/v3/suggest?query=Watermolen%2021%20Edam

在您的浏览器中试试 URL,看看它是否有您需要的数据。 然后以这种方式在您的代码中获取 JSON 数据。

data = request.get(url).json()