Skip to content

Instantly share code, notes, and snippets.

@altbdoor
Created March 21, 2023 11:06
Show Gist options
  • Save altbdoor/8928d07a8a7f94a77de3d6e31b061f9c to your computer and use it in GitHub Desktop.
Save altbdoor/8928d07a8a7f94a77de3d6e31b061f9c to your computer and use it in GitHub Desktop.
Gather duck emotes
#!/usr/bin/env python3
import urllib.request
import urllib.parse
from bs4 import BeautifulSoup
base_url = 'https://www.sigstick.com/stickers'
params = { 'author': 'kal (we-巫巴多-duck)' }
url = f'{base_url}?{urllib.parse.urlencode(params)}'
with urllib.request.urlopen(url) as res:
html = res.read().decode('utf8')
soup = BeautifulSoup(html, 'html.parser')
packs = soup.css.select('.sticker-packs > a')
for pack in packs:
pack_href = pack.attrs['href']
pack_href = f'https://www.sigstick.com{pack_href}'
with urllib.request.urlopen(pack_href) as res:
html = res.read().decode('utf8')
soup = BeautifulSoup(html, 'html.parser')
stickers = soup.css.select('img[alt="sticker"]')
for stick in stickers:
stick_href = f'https://example.com{stick.attrs["src"]}'
img_src = urllib.parse.urlparse(stick_href).query
img_src = urllib.parse.parse_qs(img_src)['url'][0]
img_src = img_src.replace('thumb128', 'thumb256')
print(img_src)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment