MCPcopy Index your code
hub / github.com/geekcomputers/Python / download_wallpapers_1080p

Function download_wallpapers_1080p

Google_Image_Downloader/image_grapper.py:75–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74
75def download_wallpapers_1080p():
76 cont = set() # Stores the links of images
77 temp = set() # Refines the links to download images
78
79 print("Enter data to download wallpapers: ")
80 data = input()
81 search_query = {"q": data}
82 search = urlencode(search_query)
83 print(search)
84 g = WALLPAPERS_KRAFT + search
85 request = Request(g, headers=usr_agent)
86 r = urlopen(request).read()
87 sew = BeautifulSoup(r, "html.parser")
88 count = 0
89 for links in sew.find_all("a"):
90 if "wallpaperscraft.com/download" in links.get("href"):
91 cont.add(links.get("href"))
92 for re in cont:
93 # print all valid links
94 # print('https://wallpaperscraft.com/image/' + re[31:-10] + '_' + re[-9:] + '.jpg')
95
96 temp.add(
97 "https://wallpaperscraft.com/image/" + re[31:-10] + "_" + re[-9:] + ".jpg"
98 )
99
100 # Goes to Each link and downloads high resolution images
101
102 for re in temp:
103 rs = requests.get(re)
104 with open("img" + str(count) + ".jpg", "wb") as file:
105 file.write(rs.content)
106
107 # urlretrieve(re, 'img' + str(count) + '.jpg')
108
109 count += 1
110
111 return True
112
113
114###################

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected