fork download
  1. from grab import Grab
  2. import re
  3. from urllib.request import urlopen
  4. link = input('вставь ссылку на тред: ')
  5. g = Grab()
  6. g.go(link)
  7. raw_list_of_image_attrs = g.css_list("div[id^='post-body']>div.images>figure.image>figcaption.file-attr>a.desktop")
  8. img_urls = []
  9. for url in raw_list_of_image_attrs:
  10. end = url.attrib['href']
  11. img_urls.append('https://2...content-available-to-author-only...h.hk'+end)
  12. for img in img_urls:
  13. m = re.search(r"\d+\.\w+", img)
  14. file_name = m.group()
  15. image = urlopen(img).read()
  16. file = open(file_name, "wb")
  17. file.write(image)
  18. file.close()
Runtime error #stdin #stdout #stderr 0.03s 9440KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named grab