Python 爬虫入门三(网页) 获取标签属性 def getUrlByReg(): html = urlopen('网页URL') bs = BeautifulSoup(html, 'html.parser') images = bs.findAll('img') for img in images: print(img['src'])
Python 爬虫入门二(标签) ⑤通过标签及样式名获取 # coding=UTF-8 from urllib2 import urlopen, HTTPError from bs4 import BeautifulSoup def getName(url): try: html = urlopen(url) except HTTPError as e: return e try: bs = BeautifulSoup(html.read(), 'html..