Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 509769f

Browse files
committed
add wallpapers scraper
1 parent 9dcc64a commit 509769f

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# r_wallpapers.py
2+
Save the top 5 posts from 'hot' from the wallpapers subreddit.
3+
4+
### Prerequisites
5+
```pip install praw```
6+
### How to run the script
7+
pyton r_wallpapers.py
8+
9+
### Screenshot/GIF showing the sample use of the script
10+
![usage](usage.jpg)
11+
12+
## *Author Name*
13+
Made with ♥ by [valterm](github.com/valterm)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import praw
2+
import urllib.request
3+
4+
#An app will need to be registered with reddit under https://www.reddit.com/prefs/apps
5+
reddit = praw.Reddit(client_id='clientid', \
6+
client_secret='secret', \
7+
#recommended user agent format: platform:id:version
8+
user_agent='useragent', \
9+
username='username', \
10+
password='password')
11+
12+
13+
#Define subreddit
14+
subreddit = reddit.subreddit("wallpapers")
15+
16+
#Loop through the first 5 posts sorted by 'hot'
17+
for submission in subreddit.hot(limit=5 ):
18+
#Get the url of the post
19+
url=submission.url
20+
#Define the filename
21+
filename = submission.title + '.jpg'
22+
#Save the image
23+
urllib.request.urlretrieve(url, filename)
24+
25+
26+
27+
28+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
praw==7.1.0
7.57 KB
Loading

0 commit comments

Comments
 (0)