<p>要获取特定邮政编码的联系人,可以使用以下示例:</p>
<pre><code>import requests
from bs4 import BeautifulSoup
url = 'https://www.ybpn.de/ihre-parfuemerien/'
data = {'tx_ybpn_storefinder[searchReq][term]': '80331'}
soup = BeautifulSoup(requests.get(url).content, 'html.parser')
data['tx_ybpn_storefinder[__trustedProperties]'] = soup.select_one('#storefinder [name*=__trustedProperties]')['value']
soup = BeautifulSoup(requests.post(url, data=data).content, 'html.parser')
for item in soup.select('.storefinder__list-item'):
print(item.select_one('.storefinder-item__title').get_text(strip=True))
print(item.select_one('.storefinder-item__adress').get_text(strip=True, separator='\n'))
print(item.select_one('.storefinder-item__contact').get_text(strip=True))
print('-' * 80)
</code></pre>
<p>印刷品:</p>
<pre><code>Parfümerie Brückner
Rindermarkt 1
80331
München
Tel.:+49 89 263181
Parfümerie Brückner
Marienplatz 8
80331
München
Tel.:+49 89 223874
City Parfümerie Rathjen
Tal 14
80331
München
Tel.:+49 89 2285222
Die kleine Theatiner Parfümerie
Theatiner Straße 35
80333
München
Tel.:+49 89 267919
City Parfümerie Rathjen
Stachus Passagen Karlsplatz 1. UG
80335
München
Tel.:+49 89 55 4009
...and so on.
</code></pre>