# Answer on Question #43112 - Programming - Pythonimport requestsfrom lxml import htmltree = html.parse("https://www.f-secure.com/en/web/corporation_global/contact/offices/europe")flags = tree.xpath("//img[contains(@src, 'ico-active-lang')]")for flag in flags: file_name = flag.attrib['src'].split('-')[-1] src = 'https://www.f-secure.com' + flag.attrib['src'] r = requests.get(src) with open(file_name, 'wb') as f: f.write(r.content)flags = tree.xpath("//img[contains(@src, 'corporation_global')]")for flag in flags: file_name = flag.attrib['src'].split('/')[-1] src = 'https://www.f-secure.com' + flag.attrib['src'] r = requests.get(src) with open(file_name, 'wb') as f: f.write(r.content)
Comments