Is there someone that can make this script download multiple pages, instead of one single page?
This is a script in Python:
import json, urllib
page_data = urllib.urlopen("http://example.com/wp-content/themes/example/html5system/request/example-8/get/1/").read()
js = json.loads(page_data)
#print js['page']
with open('page1.svg', 'wb') as f_out:
f_out.write(js['page'].encode('utf-8'))
import json, urllib
for i in range(1,301): # loop from 1 to 300
page_data = urllib.urlopen("http://example.com/wp-content/themes/example/html5system/request/example-8/get/%d/" % i).read()
js = json.loads(page_data)
with open('page%d.svg' % i, 'wb') as f_out: # save each page in a separate svg
f_out.write(js['page'].encode('utf-8'))
f_out.close()
I just added a simple loop around your existing code which runs for the numbers 1 to 300. I then did a string replacement '%d' % i
which inserts the value of i
where the %d
is located in the string. I also did the same thing for the file name, so each page is saved to a separate .svg file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.