Created
March 13, 2020 12:55
-
-
Save CXXN008/a690c493d832310f9858878e1e5dc977 to your computer and use it in GitHub Desktop.
get_mob_count
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 | |
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