Skip to content
import requests
from bs4 import BeautifulSoup
url = "https://www.postcrossing.com/postal-monitor"
response = requests.get(url)
soup = BeautifulSoup(response.content)
restriction_country = "Belarus"
country_ids = {}
for country in soup.findAll("details"):
    key = country.get('id')
    value = country.i.get('title').replace(' flag', '')
    country_ids[key] = value
country_ids
result = []
for key, value in country_ids.items():
    tmp = soup.findAll("details", {"id": key})
    if restriction_country in tmp[0].text:
        result.append(value)
result.remove(restriction_country)
result
len(result)

50, 48!, 49, 50, 49, 51, 53


4 hidden cells
Hidden code

1 hidden cell
r2 = set(list_53).difference(set(list_49))
print(r2)