fork download
  1. # 遊園地
  2. #
  3. #ライブラリの読み込み
  4. import bs4
  5. import urllib
  6. import requests
  7. import urllib.error
  8. import urllib.request
  9.  
  10.  
  11. # 対象のURL
  12. url='http://m...content-available-to-author-only...g.net/11438.html'
  13.  
  14.  
  15. # URLの情報を取得
  16. r = requests.get(url)
  17. soup = bs4.BeautifulSoup(r.content)
  18.  
  19.  
  20. # ページに存在するimgタグを検索
  21. for link in soup.find_all('img'):
  22. # 画像URLを取得
  23. img_url = link.get('src')
  24.  
  25. #print (img_url)
  26. #print(img_url.split('/')[-1])
  27.  
  28. try:
  29. urllib.request.urlretrieve(img_url,img_url.split('/')[-1])
  30. except urllib.error.URLError as e:
  31. print(e)
Runtime error #stdin #stdout #stderr 0.18s 26884KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 6, in <module>
ImportError: No module named 'requests'