Hi i am trying to do web scraping in pyhton but it returns empty string.
I couldn't solve the problem as I am a beginner. As far as I researched, I get a
TypeError: list indices must be integers or slices, not str
when I do it, can you help?
When I use this shape it returns empty data
import requests
from bs4 import BeautifulSoup
import pandas as pd
from urllib import response
kitapurl = "https://1000kitap.com/alintilar"
response = requests.get(kitapurl)
soup = BeautifulSoup(response.content,"html.parser")
gelen_ana_veri = soup.find_all('span',attrs={'class':'text-alt'})
print(gelen_ana_veri)
but if i do it this way i get type error
import requests
from bs4 import BeautifulSoup
import pandas as pd
from urllib import response
kitapurl = "https://1000kitap.com/alintilar"
response = requests.get(kitapurl)
soup = BeautifulSoup(response.content,"html.parser")
gelen_ana_veri= soup.find_all('meta',attrs={'property':'og:description'})['content']
print(gelen_ana_veri)
The error i got
Traceback (most recent call last):
File "c:\Users\fratk\OneDrive\Belgeler\twbot\1001kitap.py", line 11, in <module>
elem = soup.find_all('meta',attrs={'property':'og:description'})['content']
TypeError: list indices must be integers or slices, not str