November 2017
Intermediate to advanced
226 pages
5h 59m
English
Check out this URL-- https://www.packtpub.com/all?search=&offset=12&rows=&sort=. Here, the query string variable that defines the page number (offset) is multiples of 12:
To download all the images in all of these pages, we can rewrite the previous recipe as follows:
import urllib.request import urllib.parse import re from os.path import basename
url = 'https://www.packtpub.com/' queryString = 'all?search=&offset='
for i in range(0, 200, 12): query = queryString + str(i) url += query print(url) response = urllib.request.urlopen(url) source = response.read() file = open("packtpub.txt", "wb") file.write(source) file.close() ...Read now
Unlock full access