GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python/web_programming/instagram_pic.py at master · https-github-com-nzysoft/Python Expand file tree/ Copy pathinstagram_pic.pyMore file actions 16 lines (14 loc) · 654 Bytes / Copy pathinstagram_pic.pyFile metadata and controls16 lines (14 loc) · 654 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 from datetime import datetime import requests from bs4 import BeautifulSoup if __name__ == "__main__": url = input("Enter image url: ").strip() print(f"Downloading image from {url} ...") soup = BeautifulSoup(requests.get(url).content, "html.parser") # The image URL is in the content field of the first meta tag with property og:image image_url = soup.find("meta", {"property": "og:image"})["content"] image_data = requests.get(image_url).content file_name = f"{datetime.now():%Y-%m-%d_%H:%M:%S}.jpg" with open(file_name, "wb") as fp: fp.write(image_data) print(f"Done. Image saved to disk as {file_name}.") |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |