Q
Q
Qvint012020-02-03 18:38:24
Python
Qvint01, 2020-02-03 18:38:24

How to put all strings in one list?

Greetings, there is a photo url parser, but they are all written as separate lines

spoiler
5e383e0c0aa08743403458.png

So how do you put them all on one list?
the code
spoiler

import requests 
from bs4 import BeautifulSoup 
import urllib.request
import random
from time import sleep

url = "https://www.creativeshrimp.com/top-30-artworks-of-beeple.html"

source_code = requests.get(url)

plain_text = source_code.text

soup = BeautifulSoup(plain_text)

for link in soup.find_all("a",{"class":"lightbox"}):
    href = link.get('href')
    print(href)
    
    img_name = random.randrange(1,10)
    
    full_name = str(img_name) + ".jpg"
    
    sleep(0.2)


Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2020-02-03
@Qvint01

link = [link.get('href') for link in soup.find_all("a",{"class":"lightbox"})]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question