updatedversion

master
flem 2 years ago
parent 2eceb7f093
commit 7eae4c2aa6

@ -3,6 +3,7 @@ import json
import requests import requests
import mwclient import mwclient
import os import os
import urllib.parse
data=request.urlopen('https://pzwiki.wdka.nl/mw-mediadesign/api.php?action=parse&page=User:FLEM/Notebook&format=json').read() data=request.urlopen('https://pzwiki.wdka.nl/mw-mediadesign/api.php?action=parse&page=User:FLEM/Notebook&format=json').read()
print(data) print(data)
@ -24,8 +25,8 @@ print(text)
for image in images: for image in images:
here we download images #here we download images
S = requests.Session() S = requests.Session()
URL = "https://pzwiki.wdka.nl/mw-mediadesign/api.php" URL = "https://pzwiki.wdka.nl/mw-mediadesign/api.php"
#this is wrong, it gives me the images of all the media design instead of just one page #this is wrong, it gives me the images of all the media design instead of just one page
@ -46,7 +47,7 @@ for image in images:
for image in IMAGES: for image in IMAGES:
imageurl = image["url"] imageurl = image["url"]
filename = image["title"].replace('File:', '') filename = image["title"].replace('File:', '').replace(' ', '_')
print(imageurl) print(imageurl)
print(filename) print(filename)
@ -61,6 +62,7 @@ html=text.split("\n")
new_html="" new_html=""
for line in html: for line in html:
for image in images: for image in images:
image=urllib.parse.quote_plus(image)
#replace html img element #replace html img element
if image in line: if image in line:
new=f"""<div class="image"><img src="{image}"></div>""" new=f"""<div class="image"><img src="{image}"></div>"""

Loading…
Cancel
Save