目次
PyQueryのインストール
#pip install pyquery
実際にやってみる
#!/usr/bin/python from urllib.parse import urljoin from pyquery import PyQuery as pq from pprint import pprint url = 'http://www.yahoo.co.jp' dom = pq(url) result = set() for img in dom('img').items(): img_url = img.attr['src'] if img_url.startswith('http'): result.add(img_url) else: result.add(urljoin(url, img_url)) pprint(result)