Answer the question
In order to leave comments, you need to log in
How to choose a random string?
hello i have a code
import requests
from json import loads
from bs4 import BeautifulSoup
import random
s = requests.session()
s.headers.update({'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0'})
r = s.get('https://www.google.ru/search?q=кот&tbm=isch')
soup = BeautifulSoup(r.text, "html.parser")
for i in range(0,10):
for text in soup.findAll(attrs={'class': 'rg_meta notranslate'}):
text = loads(text.text)
print(text['ou'])
Answer the question
In order to leave comments, you need to log in
from random import choice
soup = BeautifulSoup(r.text, "html.parser")
elems = soup.findAll(attrs={'class': 'rg_meta notranslate'})
pic = loads(choice(elems).text)['ou']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question