공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
# coding: utf-8
|
|
import sys, re, urllib.request, ssl
|
|
from bs4 import BeautifulSoup
|
|
|
|
ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
|
|
UA={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
|
|
|
|
def get(url):
|
|
req=urllib.request.Request(url, headers=UA)
|
|
raw=urllib.request.urlopen(req, timeout=30, context=ctx).read()
|
|
return BeautifulSoup(raw, 'html.parser')
|
|
|
|
url=sys.argv[1]
|
|
sp=get(url)
|
|
# find likely content container
|
|
for sel in ['#contents','#content','.contents','.content','#sub_content','.sub_content','#container','.cont_area','.board_view','.bbs_view']:
|
|
n=sp.select_one(sel)
|
|
if n:
|
|
imgs=n.find_all('img')
|
|
print(f"== {sel}: imgs={len(imgs)}")
|
|
for i in imgs[:30]:
|
|
print(" IMG", (i.get('src') or '')[:90], '| alt=', (i.get('alt') or '')[:40])
|
|
ifr=n.find_all('iframe')
|
|
for f in ifr[:10]:
|
|
print(" IFRAME", (f.get('src') or '')[:90])
|
|
break
|
|
print("---ALL IMG count in page:", len(sp.find_all('img')))
|