Created
March 23, 2022 04:56
-
-
Save makzan/89d3c671911df62ff7f915c843d729c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
from datetime import date | |
from urllib.request import urlretrieve | |
y,m,d = date.today().isoformat().split('-') | |
url = f"http://www.macaodaily.com/html/{y}-{m}/{d}/node_2.htm" | |
res=requests.get(url) | |
res.encoding="utf-8" | |
soup=BeautifulSoup(res.text, "lxml") | |
element = soup.select_one('[usemap="#PagePicMap"]') | |
src = element["src"].replace("../","") | |
image_url = f"http://www.macaodaily.com/{src}" | |
extension = image_url.split('.')[-1] | |
print(image_url) | |
urlretrieve(image_url, f"macao-daily-{y}-{m}-{d}.{extension}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment