initial commit
This commit is contained in:
50
README.md
Normal file
50
README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Giphy GIF Downloader
|
||||
|
||||
This script downloads GIFs from Giphy pages. You provide a list of Giphy URLs, and the script will scrape the page to find the direct GIF link and download it.
|
||||
|
||||
## How It Works
|
||||
|
||||
The script reads a list of Giphy page URLs from `links.txt`, then visits each page to find the direct `.gif` image URL. It then downloads the GIF and saves it into the `downloaded_gifs` directory, using the GIF's unique ID as the filename.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Python 3
|
||||
- `requests` library
|
||||
- `beautifulsoup4` library
|
||||
|
||||
## Installation
|
||||
|
||||
1. **Clone the repository or download the files.**
|
||||
|
||||
2. **Install the required Python libraries:**
|
||||
```bash
|
||||
pip install requests beautifulsoup4
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
1. **Add Giphy URLs to `links.txt`**:
|
||||
Open the `links.txt` file and add the Giphy page URLs you want to download. Each URL should be on a new line.
|
||||
|
||||
Example `links.txt`:
|
||||
```
|
||||
https://giphy.com/gifs/hello-hi-hey-l41lZxzroU33typuU
|
||||
https://giphy.com/gifs/cat-computer-hacker-J1G7rIvoyz4cwaqXWo
|
||||
```
|
||||
|
||||
2. **Run the script**:
|
||||
Execute the Python script from your terminal:
|
||||
```bash
|
||||
python giphy-downloader.py
|
||||
```
|
||||
|
||||
3. **Find your GIFs**:
|
||||
The script will create a `downloaded_gifs` directory (if it doesn't already exist) and save all the downloaded GIFs there.
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
.
|
||||
├── giphy-downloader.py # The main Python script
|
||||
├── links.txt # Your list of Giphy URLs
|
||||
└── downloaded_gifs/ # Directory where GIFs are saved
|
||||
39
giphy-downloader.py
Normal file
39
giphy-downloader.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import os
|
||||
import re
|
||||
|
||||
# Read URLs from links.txt (one per line, skipping empty lines)
|
||||
with open("links.txt", "r", encoding="utf-8") as f:
|
||||
giphy_urls = [line.strip() for line in f if line.strip()]
|
||||
|
||||
save_dir = "downloaded_gifs"
|
||||
os.makedirs(save_dir, exist_ok=True)
|
||||
|
||||
for url in giphy_urls:
|
||||
print(f"Processing {url}")
|
||||
try:
|
||||
resp = requests.get(url, headers={"User-Agent": "Mozilla/5.0"})
|
||||
soup = BeautifulSoup(resp.text, "html.parser")
|
||||
gif_img = soup.find("img", class_="giphy-gif-img")
|
||||
if not gif_img:
|
||||
print(" Could not find gif image.")
|
||||
continue
|
||||
gif_url = gif_img["src"]
|
||||
|
||||
# Use the unique ID from the GIF URL as the filename
|
||||
m = re.search(r'/([A-Za-z0-9]+)(?:/giphy\.gif)?$', gif_url)
|
||||
if m:
|
||||
unique_id = m.group(1)
|
||||
else:
|
||||
unique_id = gif_url.split("/")[-2] # fallback
|
||||
|
||||
out_path = os.path.join(save_dir, f"{unique_id}.gif")
|
||||
with requests.get(gif_url, stream=True) as gif_resp:
|
||||
gif_resp.raise_for_status()
|
||||
with open(out_path, "wb") as f:
|
||||
for chunk in gif_resp.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
print(f" Saved to {out_path}")
|
||||
except Exception as e:
|
||||
print(f" Failed to download {url}: {e}")
|
||||
51
links.txt
Normal file
51
links.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
https://giphy.com/gifs/if-youre-reading-this-its-too-late-IW71LHYHgD4oU
|
||||
https://giphy.com/gifs/90s-rave-TfvYtCkCdoc6c
|
||||
https://giphy.com/gifs/bass-face-joe-dart-playing-dCAZGW5DqUGoJhlwcH
|
||||
https://giphy.com/gifs/dj-feeling-it-super-greg-2WGLWXvZOTnPovjgxj
|
||||
https://giphy.com/gifs/126bpm-dancingatclub-L0qTl8hl84EDly62J1
|
||||
https://giphy.com/gifs/gymnastics-firefly-pose-Q6OpQ0hTfoMlzAJNxh
|
||||
https://giphy.com/gifs/breakdancing-13O5QFFTXMY4Ni
|
||||
https://giphy.com/gifs/poseonfx-pose-posefx-on-fx-kEiKdgFxZicNmkVQ0Z
|
||||
https://giphy.com/gifs/SalmanKhanFilms-AqiO9VOGWcnd6zUrqS
|
||||
https://giphy.com/gifs/nba-on-court-2WdEjhM4ig6Et2AMEB
|
||||
https://giphy.com/gifs/thread-edition-hyper-YTtqB2j5EN7IA
|
||||
https://giphy.com/gifs/filmeditor-christmas-movies-gremlins-3ofT5HPgDvu4QsVF3G
|
||||
https://giphy.com/gifs/movie-film-dancing-QpTMRCuLQv9F6
|
||||
https://giphy.com/gifs/coachlain-dancing-bad-student-background-dancer-PR02v69emoQea5AHzu
|
||||
https://giphy.com/gifs/dance-dancing-dancer-BkL4Vyz0z2iYQMhwFw
|
||||
https://giphy.com/gifs/teletubbiesofficial-dance-funny-XBcWgQZJpYTCac3o61
|
||||
https://giphy.com/gifs/dancing-crazy-mWblFbJN5hg9ndNIlg
|
||||
https://giphy.com/gifs/nickelodeon-dance-crazy-party-mEJDrZrjXnily6KFW8
|
||||
https://giphy.com/gifs/dance-party-v9tjYT6usq2s
|
||||
https://giphy.com/gifs/dance-happy-crazy-EgClH12F524o0
|
||||
https://giphy.com/gifs/dance-crazy-ruqrwD8jFH6Du
|
||||
https://giphy.com/gifs/vigovideo-dancing-danando-crazy-guy-H7fEGyOn75WVxbkf0V
|
||||
https://giphy.com/gifs/Ringthebellsoftware-dance-sexy-crazy-3KDLjJ1ujuW4Iw9ySk
|
||||
https://giphy.com/gifs/bptheofficial-party-hyper-yee-JcXBBFmjpnt3Azllxa
|
||||
https://giphy.com/gifs/FqX5nuwnwLsZphI1yW
|
||||
https://giphy.com/gifs/wassie-bywassies-wassies-aM5F2lOmW20Wn6QtWW
|
||||
https://giphy.com/gifs/country-dezmineann-dezmine-d7fKljD4WRftoHF031
|
||||
https://giphy.com/gifs/fun-girl-crazy-OR1aQzSbvf4DrgX22C
|
||||
https://giphy.com/gifs/Pdentmt-crazy-loco-sexy-latina-BnUrkclZ3aSukjshj0
|
||||
https://giphy.com/gifs/Fantastic-Snacks-yup-fantasticsnacks-yuptothecup-b6GKNxT8xJm1HOaAtA
|
||||
https://giphy.com/gifs/yentlendeboer-dancing-yentl-en-de-boer-christine-AS7GIJRxYhQh3Rcbxe
|
||||
https://giphy.com/gifs/katie-nolan-u1YloV8vwpALS
|
||||
https://giphy.com/gifs/are-bouncing-slowmo-OCqNtfK51QcsU
|
||||
https://giphy.com/gifs/are-bouncing-slowmo-bhQ6Jn1AFopmU
|
||||
https://giphy.com/gifs/bounce-bouncing-P3vc6Z3zVT1Go
|
||||
https://giphy.com/gifs/bouncing-party-RBLyUtigywgrm
|
||||
https://giphy.com/gifs/alanjackson-alan-jackson-summertime-blues-w1DgltKHfXvt7e9Xqf
|
||||
https://giphy.com/gifs/stefflondon-stefflon-don-l41JJtp27xa5jRHLa
|
||||
https://giphy.com/gifs/CircusRecords-circus-records-gunfingers-conrank-pPK4ou9lheaHtQIZRa
|
||||
https://giphy.com/gifs/ufonetwork-running-man-arizona-shufflers-3dwinvibin-nTMDCso0RfkmHfjBpU
|
||||
https://giphy.com/gifs/buzzfeed-dance-dnb-african-kcLrffHbM57Xet7eWN
|
||||
https://giphy.com/gifs/twentyonepilots-twenty-one-pilots-overcompensate-X2qLoLVd1Bkmhtynwy
|
||||
https://giphy.com/gifs/xwTzbG6rfO81y
|
||||
https://giphy.com/gifs/television-vintage-retro-pVUxYuntLtVoA
|
||||
https://giphy.com/gifs/BeMorePirate-rave-raver-raving-StcyOQt02yHj8Ie2ID
|
||||
https://giphy.com/gifs/halloween-costumes-26BkMeZiOiA9t2cKc
|
||||
https://giphy.com/gifs/5UJyoBqHtHmU0
|
||||
https://giphy.com/gifs/tripping-raver-raving-289KPZoUzTwmWeEoqS
|
||||
https://giphy.com/gifs/dancing-boy-rave-PvKlwYTiKATRe
|
||||
https://giphy.com/gifs/126bpm-dancingatclub-L0qTl8hl84EDly62J1
|
||||
https://giphy.com/gifs/dogs-dancefloor-existentialist-2uxxTQMhLeMH8mK0Jm
|
||||
Reference in New Issue
Block a user