Created
May 6, 2020 03:24
-
-
Save cmhobbs/d5887c4bf3c5144f7d56f3ed187589b5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
import random | |
from bs4 import BeautifulSoup | |
# set up some crap | |
URL = "https://www.sarna.net/wiki/Weapons_and_Equipment_Lists" | |
res = requests.get(URL).text | |
soup = BeautifulSoup(res,'lxml') | |
equipment_tables = soup.findAll('table',{'class':'wikitable'}) | |
equipment_list = [] | |
# build the list | |
for equipment in equipment_tables: | |
rows = equipment.find_all('tr') | |
for row in rows: | |
columns = row.find_all('td') | |
if len(columns) != 0: | |
equipment_list.append(columns[0].a.get('title')) | |
# spew out an item | |
print(random.choice(equipment_list)) |
This file contains hidden or 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
(base) cmhobbs@mare-crisium:~/src/sarnagrab | |
$ for run in {1..10}; do python sarnagrab.py; done | |
Rocket Launcher 20 | |
LB 10-X AC | |
ProtoMech Autocannon/4 | |
MML-3 | |
Ultra AC/2 | |
Narc Missile Beacon | |
HAG-20 | |
Magshot | |
Chemical Medium Laser | |
Active Probe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment