Skip to content

Instantly share code, notes, and snippets.

@CXXN008
Created March 13, 2020 12:55
Show Gist options
  • Save CXXN008/a690c493d832310f9858878e1e5dc977 to your computer and use it in GitHub Desktop.
Save CXXN008/a690c493d832310f9858878e1e5dc977 to your computer and use it in GitHub Desktop.
get_mob_count
import requests
from bs4 import BeautifulSoup as B
h = 'http://gametsg.techbang.com'
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:
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^="#"]'))
url = f'{h}/maplestory/{j["href"]}'
line = f'{ map_n}|{mob_k}|{mob_c}|{url}'
print(line)
res += line
open('r.text', 'w').write(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment