Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BGTradePicDownload.py
import requests as rq
import pandas as pd
from bs4 import BeautifulSoup
from tqdm import tqdm
page = rq.get('https://boardgamegeek.com/xmlapi2/collection?username=Masu&trade=1').content
soup = BeautifulSoup(page, 'xml')
df = pd.Series(list(map(lambda x: x.text, soup.findAll('image')))).to_frame('url')
df['title'] = pd.Series(list(map(lambda x: x.text.replace(' ', '').replace('!', '').replace(':', ''), soup.findAll('name'))))
for i, row in tqdm(list(df.iterrows())):
data = rq.get(row.url).content
with open('Downloads/{}.{}'.format(row.title, row.url.split('.')[-1]), 'wb') as fout:
fout.write(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.