Created
April 10, 2020 10:06
-
-
Save CXXN008/acff431661b3b007813c20de04ab5741 to your computer and use it in GitHub Desktop.
maplestoy: get arcane river's monster count / map size etc...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup as B | |
from PIL import Image as I | |
from io import BytesIO | |
h = 'http://gametsg.techbang.com' | |
res = '' | |
def main(): | |
global res | |
for i in range(21, 28): | |
r = requests.get( | |
f'{h}/maplestory/index.php?view=map&level={i}').content.decode('utf-8') | |
s = B(r, features="lxml") | |
map_l = s.select('.mid1') | |
for j in map_l: | |
isArcaneRiver = j.parent.text.find('奧術之河') > 0 | |
if isArcaneRiver: | |
r = requests.get( | |
f'{h}/maplestory/{j["href"]}').content.decode('utf-8') | |
s = B(r, features="lxml") | |
mob_k = [i.text for i in s.select('td[width="33%"]')[ | |
1].select('tr')] | |
map_n = s.select(".big12")[0].text | |
mob_c = len(s.select("table[width=\"660\"]")[ | |
1].select('a[href^="#"]')) | |
map_img = s.select('img')[4] | |
print(f'\n{map_img}\n') | |
img_url = f'{h}/maplestory/{map_img["data-src"]}' | |
img = I.open(BytesIO(requests.get(img_url).content)) | |
width, height = img.size | |
url = f'{h}/maplestory/{j["href"]}' | |
line = f'{ map_n}|{mob_k}|{mob_c}|{width}|{height}|{width*height}|{url}\n' | |
print(line) | |
res += line | |
open('arcane.txt', 'w',encoding="utf-8").write(res) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment