twitch_emotes.py
· 1.1 KiB · Python
Raw
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup as Soup
from sys import argv
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0' ,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' ,
'Accept-Language': 'en-US,en;q=0.5',
'Content-Type': 'application/x-www-form-urlencoded' ,
'Origin': 'https://twitchemotes.com' ,
'Alt-Used': 'twitchemotes.com' ,
'Connection': 'keep-alive' ,
'Referer': 'https://twitchemotes.com/channels/8683614' ,
'Upgrade-Insecure-Requests': '1' ,
'Sec-Fetch-Dest': 'document' ,
'Sec-Fetch-Mode': 'navigate' ,
'Sec-Fetch-Site': 'same-origin' ,
'Sec-Fetch-User': '?1' ,
'TE': 'trailers'
}
channel = argv[1] if len(argv) > 1 else 'zfg1'
channel_page = requests.post("https://twitchemotes.com/search/channel", data={"query": channel, "source": "nav-bar"}, headers=headers).text
soup = Soup(channel_page, "html.parser")
print(f"mkdir {channel}")
for img in soup.find_all("img", {"class": "emote"}):
print(f"curl {img['src']} -o {channel}/{img['data-regex']}.png")
| 1 | #!/usr/bin/env python3 |
| 2 | import requests |
| 3 | from bs4 import BeautifulSoup as Soup |
| 4 | from sys import argv |
| 5 | |
| 6 | headers = { |
| 7 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0' , |
| 8 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' , |
| 9 | 'Accept-Language': 'en-US,en;q=0.5', |
| 10 | 'Content-Type': 'application/x-www-form-urlencoded' , |
| 11 | 'Origin': 'https://twitchemotes.com' , |
| 12 | 'Alt-Used': 'twitchemotes.com' , |
| 13 | 'Connection': 'keep-alive' , |
| 14 | 'Referer': 'https://twitchemotes.com/channels/8683614' , |
| 15 | 'Upgrade-Insecure-Requests': '1' , |
| 16 | 'Sec-Fetch-Dest': 'document' , |
| 17 | 'Sec-Fetch-Mode': 'navigate' , |
| 18 | 'Sec-Fetch-Site': 'same-origin' , |
| 19 | 'Sec-Fetch-User': '?1' , |
| 20 | 'TE': 'trailers' |
| 21 | } |
| 22 | |
| 23 | channel = argv[1] if len(argv) > 1 else 'zfg1' |
| 24 | channel_page = requests.post("https://twitchemotes.com/search/channel", data={"query": channel, "source": "nav-bar"}, headers=headers).text |
| 25 | soup = Soup(channel_page, "html.parser") |
| 26 | |
| 27 | print(f"mkdir {channel}") |
| 28 | for img in soup.find_all("img", {"class": "emote"}): |
| 29 | print(f"curl {img['src']} -o {channel}/{img['data-regex']}.png") |