This repository was archived by the owner on Dec 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
Scripts/Web_Scrappers/Reddit_wallpapers_scraper Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
1
+ praw == 7.1.0
You can’t perform that action at this time.
0 commit comments