Seite 1 von 1
Bilder einer Website herunterladen
Verfasst: Sonntag 7. Oktober 2018, 14:00
von DeadBarney
Moin, ich stehe vor folgender Aufgabe.
Auf der Internetseite
https://apod.nasa.gov/apod/archivepix.html sind mehrere Bilder hinterlegt, die ich runterladen möchte und als Bildschirmhintergrund verwenden möchte. Da ich Pythonneuling bin, bräuchte ich ein paar Ideen und Ansätze, wie ich diese am einfachsten tun kann.
LG DB
Re: Bilder einer Website herunterladen
Verfasst: Sonntag 7. Oktober 2018, 16:56
von sls
Eine Idee wäre, das urllib-Modul zu verwenden. Auch requests ist gut. Ein Ansatz wäre, die jeweilige Doku zu lesen, und sich bei Verständnisproblemen oder fehlgeschlagenen Versuchen wieder hier zu melden.
Re: Bilder einer Website herunterladen
Verfasst: Sonntag 7. Oktober 2018, 18:33
von __blackjack__
Dann bräuchte man noch einen HTML-Parser, bzw. eine Bibliothek um das HTML nach Links und Bildern absuchen zu können. Hier ist BeautifulSoup recht beliebt.
Re: Bilder einer Website herunterladen
Verfasst: Freitag 26. Oktober 2018, 18:06
von DeadBarney
Habe es mit request versucht, worauf die Meldung kam
wollte erst probieren, ob es eine normale seite aufruft
Code: Alles auswählen
#coding= UTF-8
import urllib.request
x = urllib.request.urlopen('https://www.google.com/')
print(x.read())
ImportError: No module named request
habe es nach dieser website runtergeladen:
https://stackoverflow.com/questions/173 ... d-requests
kann es sein, dass es nicht funktioniert, weil ich Ubuntu verwende?
Re: Bilder einer Website herunterladen
Verfasst: Freitag 26. Oktober 2018, 21:56
von __blackjack__
@DeadBarney: Schau mal welche Python-Version Du verwendest und dann in der dazu passenden Dokumentation welche Module es da unter welchen Namen bzw. in welchen Packages in der Standardbibliothek gibt.
Ich persönlich würde ja das externe `requests`-Modul für so etwas verwenden.
Re: Bilder einer Website herunterladen
Verfasst: Samstag 27. Oktober 2018, 10:08
von DeadBarney
Code: Alles auswählen
python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Code: Alles auswählen
BaseHTTPServer atexit hashlib rexec
Bastion atk heapq rfc822
CDROM attr hmac rlcompleter
CGIHTTPServer audiodev hotshot robotparser
Canvas audioop html5lib runpy
ConfigParser base64 htmlentitydefs samba
Cookie bdb htmllib sched
Crypto binascii httplib select
DLFCN binhex httplib2 serial
Dialog bisect idna service_identity
DocXMLRPCServer blinker ihooks sets
FileDialog bonobo imaplib setuptools
FixTk bs4 imghdr sgmllib
HTMLParser bsddb imp sha
IN bz2 importlib shelve
MimeWriter cPickle imputil shlex
ORBit cProfile indicator_keyboard shutil
OpenSSL cStringIO inspect signal
PAM cairo io site
PIL calendar ipaddress sitecustomize
Queue caribou itertools six
ScrolledText ccm json smtpd
SimpleDialog certifi jwt smtplib
SimpleHTTPServer cgi keyword sndhdr
SimpleXMLRPCServer cgitb ldb socket
SocketServer chardet lib2to3 softwarecenter_aptd_plugins
StringIO chunk linecache spwd
TYPES cmath linuxaudiodev sqlite3
Tix cmd locale sre
Tkconstants code lockfile sre_compile
Tkdnd codecs logging sre_constants
Tkinter codeop lsb_release sre_parse
UserDict collections lxml ssl
UserList colorsys macpath stat
UserString commands macurl2path statvfs
_LWPCookieJar compileall mailbox string
_MozillaCookieJar compiler mailcap stringold
__builtin__ compizconfig markupbase stringprep
__future__ contextlib marshal strop
_abcoll cookielib math struct
_ast copy md5 subprocess
_bisect copy_reg mhlib sunau
_bsddb crypt mimetools sunaudio
_cffi_backend cryptography mimetypes symbol
_codecs csv mimify symtable
_codecs_cn ctypes mmap sys
_codecs_hk cups modulefinder sysconfig
_codecs_iso2022 curses multifile syslog
_codecs_jp datetime multiprocessing tabnanny
_codecs_kr dbhash mutex talloc
_codecs_tw dbm ndg tarfile
_collections dbus netrc tdb
_csv deb822 new telnetlib
_ctypes debconf nis tempfile
_ctypes_test debian nntplib termios
_curses debian_bundle ntpath test
_curses_panel debtagshw nturl2path textwrap
_dbus_bindings decimal numbers this
_dbus_glib_bindings defer numpy thread
_elementtree difflib oauthlib threading
_functools dircache oneconf time
_hashlib dirspec opcode timeit
_heapq dis operator tkColorChooser
_hotshot distutils optparse tkCommonDialog
_io dns os tkFileDialog
_json doctest os2emxpath tkFont
_ldb_text dsextras ossaudiodev tkMessageBox
_locale dumbdbm pango tkSimpleDialog
_lsprof dummy_thread pangocairo toaiff
_md5 dummy_threading parser token
_multibytecodec duplicity pdb tokenize
_multiprocessing easy_install pi trace
_osx_support email pickle traceback
_pyio encodings pickletools ttk
_random ensurepip pip tty
_sha enum pipes turtle
_sha256 errno piston_mini_client twisted
_sha512 exceptions pkg_resources types
_socket fcntl pkgutil ubuntu_sso
_sqlite3 filecmp platform unicodedata
_sre fileinput plistlib unittest
_ssl fnmatch popen2 urllib
_strptime formatter poplib urllib2
_struct fpectl posix urllib3
_symtable fpformat posixfile urlparse
_sysconfigdata fractions posixpath user
_sysconfigdata_nd ftplib pprint uu
_tdb_text functools profile uuid
_testcapi future_builtins pstats warnings
_threading_local gc pty wave
_tkinter gconf pwd weakref
_warnings genericpath py_compile webbrowser
_weakref getopt pyasn1 wheel
_weakrefset getpass pyasn1_modules whichdb
abc gettext pyatspi wsgiref
aifc gi pyclbr xapian
antigravity gio pydoc xdg
anydbm glib pydoc_data xdrlib
apt glob pyexpat xml
apt_inst gnome pygtk xmllib
apt_pkg gnomecanvas pygtkcompat xmlrpclib
aptdaemon gnomevfs quopri xxsubtype
aptsources gobject random zipfile
argparse grp re zipimport
array gtk readline zlib
ast gtkunixprint repr zope
asynchat gtweak requests
asyncore gzip resource
Re: Bilder einer Website herunterladen
Verfasst: Samstag 27. Oktober 2018, 18:10
von Sirius3
Na da schau an, `requests` ist schon installiert.
Re: Bilder einer Website herunterladen
Verfasst: Sonntag 28. Oktober 2018, 17:59
von DeadBarney
habe den typo korrigiert
mit
Code: Alles auswählen
#coding= UTF-8
import urllib.requests
x = urllib.requests.urlopen('https://www.google.com/')
print(x.read())
kommt trotzdem
Code: Alles auswählen
Traceback (most recent call last):
File "Bilder.py", line 2, in <module>
import urllib.requests
ImportError: No module named requests
Re: Bilder einer Website herunterladen
Verfasst: Sonntag 28. Oktober 2018, 18:03
von ThomasL
Du solltest dich entscheiden ob du urllib.request oder requests benutzen möchtest, aber urllib.requests gibt es nicht
Re: Bilder einer Website herunterladen
Verfasst: Mittwoch 31. Oktober 2018, 08:15
von RogerSt
Ich bin auch neuling.
Als ich deinen Beitrag gesehen habe, habe ich mal Goole angeschmissen und ca. 30 min später kann ich alle Bilder herunterladen. Somit kann es nicht so schwer sein.
Also ich würde mal die Basics lernen und dann Googlen.
http://lmgtfy.com/?q=python+web+image+download
Ich habe es mir bs4 und urllib gemacht.