Answer the question
In order to leave comments, you need to log in
I can’t complete the cycle, I need to sort through 1 link, then save it, a picture from the site with a new name, the cycle is different, but it works, what should I do?
there is a list of links, you need it to sort through the list by 1 link, follow it, then download the pictures each time with a new name, I tried to have several script options, who will help with the error?
1var)
import requests
from requests import Session
from bs4 import BeautifulSoup
import re
from multiprocessing.dummy import Pool as ThreadPool
#s = Session()
def get_photo_from_page():
tut = []
names = []
r = requests.get('https://vk.com/uporols_you').text
soup = BeautifulSoup(r, 'lxml')
im = soup.find_all('img', class_="ph_img")
for a in im:
s = a.get('data-src_big').split('|')[0]
tut.append(s)
y = "img%s.jpg"
for im in [y % i for i in range(1,5)]:
names.append(im)
for t, a in tut, names:
p = requests.get(t)
out = open(a, "wb")
out.write(p.content)
out.close()
def main():
get_photo_from_page()
if __name__ == '__main__':
main()
import requests
from requests import Session
from bs4 import BeautifulSoup
import re
from multiprocessing.dummy import Pool as ThreadPool
#s = Session()
def get_photo_from_page():
tut = []
r = requests.get('https://vk.com/uporols_you').text
soup = BeautifulSoup(r, 'lxml')
im = soup.find_all('img', class_="ph_img")
for a in im:
s = a.get('data-src_big').split('|')[0]
tut.append(s)
y = "img%s.jpg"
for t in tut:
p = requests.get(t)
for im in [y % i for i in range(1,5)]:
out = open(im, "wb")
out.write(p.content)
out.close()
def main():
get_photo_from_page()
if __name__ == '__main__':
main()
Answer the question
In order to leave comments, you need to log in
import requests
import bs4
tut = []
names = []
r = requests.get('https://vk.com/uporols_you').text
soup = bs4.BeautifulSoup(r, 'lxml')
im = soup.find_all('img', class_='ph_img')
for a in im:
s = a.get('data-src_big').split('|')[0]
tut.append(s)
for num, link in enumerate(tut):
p = requests.get(link)
out = open("img%s.jpg" % (num), 'wb')
out.write(p.content)
out.close()
for i in ('a', 'b', 'c', 'd'):
for x in ('1', '2', '3', '4'):
print(i + " => " + x)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question