Python'dan Json'a dönüştürmek

f_cetin

Zeptopat
Katılım
10 Ekim 2021
Mesajlar
1
Daha fazla  
Cinsiyet
Kadın
Bir siteden veri çektim şu şekilde:
İmport requests.
From BS4 import beautifulsoup.
İmport json.

URL = 'Play The Mini Crossword'
Response = requests. Get(URL)
Content = response. Content.
Soup = beautifulsoup(content, 'lxml')

Data = {}
Data['veri']=[]

a = soup.find('section', attrs={"class": "Layout-clueLists--10_Xl"})

div = a.find_all('div', attrs={"class": "ClueList-wrapper--3m-kd"})
z = div[0]

B = Z. Find('h3', attrs={"class": "cluelist-title--1-3ow"}).text
#Print(b)

C = Z. Find('ol', attrs={"class": "cluelist-list--2dd5-"})

Sayi = C. Find_all('span', attrs={"class": "clue-label--2ıdmy"})

Lists = C. Find_all('span', attrs={"class": "clue-text--3lzl7"})
For i in range(0, 5):
K = lists.text
X = sayi.text

Data['veri'].append({
"Sayi": X,
"Mesaj": K,
"Baslik": B,
})

Div1 = a. Find_all('div', attrs={"class": "cluelist-wrapper--3m-kd"})
Z1 = div1[1]

D = Z1.find('h3', attrs={"class": "cluelist-title--1-3ow"}).text
#Print(D)

E = Z1.find('ol', attrs={"class": "cluelist-list--2dd5-"})

Sayi1 = e. Find_all('span', attrs={"class": "clue-label--2ıdmy"})

Lists1 = e. Find_all('span', attrs={"class": "clue-text--3lzl7"})
For n in range(0, 5):

L = lists1[n].text
S = sayi1[n].text

data['veri'].append({

"Sayi": S,
"Mesaj": L,
"Baslik": D
})

#Cikti = {'degerler': Veri, 'degerler': Veri2}

#Cikti = {'degerler': Veri}

#Print(json. Dumps(veri))

#Json. Dumps(cikti)
 
Son düzenleyen: Moderatör:

Technopat Haberler

Geri
Yukarı