- Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathscrape.py
27 lines (19 loc) · 710 Bytes
/
scrape.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
importurllib3
importshutil
frombs4importBeautifulSoupasbs
defmain():
ur=input("Input URL Here ")
http=urllib3.PoolManager()
page=http.request('GET', ur)
soup=bs(page.data, 'html.parser')
link= ["http:"+ls.get('href') forlsinsoup.find_all('a', {"class" : "zoom"})]
forvdinsoup.find_all('source'):
link.append('http:'+vd.get('src'))
print(link)
forlninlink:
index=ln.rindex('/')
filename=ln[index+1:len(ln)]
withhttp.request('GET', ln, preload_content=False)asresp, open(filename, 'wb') asout_file:
shutil.copyfileobj(resp, out_file)
if__name__=="__main__":
main()