9/10/2023 0 Comments Python download webpage![]() ![]() The urllib module in Python 2 was the original downloading module in the Python standard library added in Python 1.2. with open ( filename, 'wb' ) as fileObj : fileObj. split ( '/' ) # Use the filename from the url. read () # Replace foo.jpg with the local filename you want to use: filename = url. requestObj = Request ( '', headers = ) responseObj = urlopen ( requestObj ) content = responseObj. ![]() Replace this with the page you want to download. # '' is a website that returns simple info about your request. version_info = 2 : # Python 2 from urllib2 import Request, urlopen # Supply a user-agent header of a common browser, since some web servers will refuse to reply to scripts without one. version_info = 3 : # Python 3 from urllib.request import Request, urlopen elif sys.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |