Do you realize that the entire site you're scraping is behind JS? Having said that, bs4 won't see a thing, which explains your result. In other words, there's no such content in the HTML you're getting back.
But, there's an API that you can query.
Here's how:
import requests
from bs4 import BeautifulSoup
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:83.0) Gecko/20100101 Firefox/83.0",
"Authorization": "Bearer 2381c6b987aea877abc6a73fe1cbc7d4a88a602c",
}
api = "https://api.blocket.se/search_bff/v1/content?cb=40&cbl1=6&cchb=1&ccsc=1&cg=1020&f=c&lim=40&mye=2017&mys=2013&page=0&sort=date"
response = requests.get(api, headers=headers).json()
print(len(response["data"]))
This should print 40, which is the number of offers.
Note: I'm not sure yet where the Bearer string is coming from, but I'll dig deeper and get back to this answer.
By the way, all the data you want comes back in that JSON so for example you can do this:
import requests
from tabulate import tabulate
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:83.0) Gecko/20100101 Firefox/83.0",
"Authorization": "Bearer 2381c6b987aea877abc6a73fe1cbc7d4a88a602c",
}
api = "https://api.blocket.se/search_bff/v1/content?cb=40&cbl1=6&cchb=1&ccsc=1&cg=1020&f=c&lim=40&mye=2017&mys=2013&page=0&sort=date"
response = requests.get(api, headers=headers).json()
print(len(response["data"]))
listing = [
[
i["subject"],
i["price"]["value"],
i["share_url"]
] for i in response["data"]
]
print(tabulate(listing, headers=["Name", "Price", "URL"]))
To get this:
Name Price URL
------------------------------------------------------------ ------- --------------------------------------
Volkswagen Golf R 2.0 4Motion DSG Euro 6 300hk 295000 https://www.blocket.se/vi/94476197.htm
Volkswagen Golf 1.6 TDI Style Eu6 110hk Nyservad 104900 https://www.blocket.se/vi/94476140.htm
Volkswagen Golf 1.4 150hk R-Line Nyservad 2Brukare 4.5/100km 173700 https://www.blocket.se/vi/94393769.htm
Volkswagen Golf GTD 2.0 TDI DSG Euro 6 184hk 189000 https://www.blocket.se/vi/92041858.htm
Volkswagen Golf 1.4 TSI DSG R-LINE APPLE CARPLAY 150hk 179000 https://www.blocket.se/vi/94258178.htm
Volkswagen Golf R 2.0 4MOTION DSG MILLTEK PANORAMA GPS 300hk 289000 https://www.blocket.se/vi/94067452.htm
Volkswagen Golf 1.0 TSI BLUEMOTION DSG LÅGMIL 110hk 169000 https://www.blocket.se/vi/93849586.htm
Volkswagen Golf R 2.0 4M DSG Panorama Facelift Euro 6 310hk 329900 https://www.blocket.se/vi/94475139.htm
Volkswagen Golf TSi 140hk DSG /R-Line/Drag/Mok 164900 https://www.blocket.se/vi/94473981.htm
Volkswagen Golf e-Golf 24.2 kWh /V-hjul/Navigation 199900 https://www.blocket.se/vi/91366004.htm
Volkswagen Golf Sportsvan 1.2 TSI DSG AUT Style EU6 159900 https://www.blocket.se/vi/93688078.htm
Volkswagen Golf 1.4 TSI Navi Drag Fullservad 140hk 122800 https://www.blocket.se/vi/94196494.htm
Volkswagen Golf GTE Hybrid 204hk B-kamera Drag Fullservad 199800 https://www.blocket.se/vi/94302825.htm
Volkswagen Golf 1.6 TDI 110HK Fjärrstyrd värmare 129000 https://www.blocket.se/vi/94433465.htm
Volkswagen Golf 1.2 TSI 110HK Aut Årsskatt 382kr 147500 https://www.blocket.se/vi/94057577.htm
Volkswagen Golf GTE 1.4 TSI DSG Sekventiell Euro 6 204hk 174900 https://www.blocket.se/vi/94469939.htm
Volkswagen Golf Alltrack 4M Eu6 184hk Premium D-värm B-kamer 164400 https://www.blocket.se/vi/94240149.htm
Volkswagen Golf 1.2 TSI BlueMotion 105hk Nyservad 84800 https://www.blocket.se/vi/94466632.htm
Volkswagen Golf 1.2 TSI 110 | Style | Komplett servicebok 114500 https://www.blocket.se/vi/92133274.htm
Volkswagen Golf 5-dr P-sensor 1.6 TDI 115hk 144800 https://www.blocket.se/vi/93528128.htm
Volkswagen Golf 5-door R 2.0 4Motion DSG Skinn Pano Dynaudio 268900 https://www.blocket.se/vi/94134128.htm
Volkswagen Golf 1.6TDI M-värm Drag Eu6 110hk 129800 https://www.blocket.se/vi/93438018.htm
Volkswagen Golf 1.2 TSI Fullservad 105hk 104800 https://www.blocket.se/vi/94342484.htm
Volkswagen Golf 1.4 TSI Multifuel | Style | M-Värme | 5-dorr 116800 https://www.blocket.se/vi/93526752.htm
Volkswagen Golf GTI 2.0 TSI 230hk Performance Euro6 239900 https://www.blocket.se/vi/91536231.htm
Volkswagen Golf 140hk / Highline Plus 114900 https://www.blocket.se/vi/89194496.htm
Volkswagen Golf 1.4 TSI / Style / 5-dörrar 99000 https://www.blocket.se/vi/93718402.htm
Volkswagen Golf Sportsvan 1.2 TSI DSG 12 månaders garanti 169900 https://www.blocket.se/vi/93729451.htm
Volkswagen Golf Sportsvan TSI 110 MASTERS 115000 https://www.blocket.se/vi/94455199.htm
Volkswagen Golf 1.2 TSI VÄLVÅRDAD STYLE 105hk 89900 https://www.blocket.se/vi/94455152.htm
Volkswagen Golf 5-dörrar 1.6 TDI BlueMotion Design sport 72900 https://www.blocket.se/vi/94454862.htm
Volkswagen Golf 1.6 TDI Aut | Darklabel | P-värmare 99000 https://www.blocket.se/vi/94131096.htm
Volkswagen Golf 5-dr GTI Performance 2.0 TSI Eu 6 245hk 234500 https://www.blocket.se/vi/94453627.htm
Volkswagen Golf 5-d GTD 2.0 TDI Premium Kamera/Värmare/Drag 169000 https://www.blocket.se/vi/94453171.htm
Volkswagen Golf GTD 2.0 184hk D-Värmare Dynaudio Välservad 174900 https://www.blocket.se/vi/94452825.htm
Volkswagen Golf 1.6TDI 105hk Style P.sensor Välservad 127900 https://www.blocket.se/vi/94452680.htm
Volkswagen Golf TDI 150hk R-Line DSG / 1.99% Ränta 195000 https://www.blocket.se/vi/93752165.htm
Volkswagen Golf 5-dörrar 1.6 TDI Design, Style 105hk 89900 https://www.blocket.se/vi/94448403.htm
Volkswagen Golf 5-dörrar 1.6 TDI DSG Sekventiell Style 105hk 119900 https://www.blocket.se/vi/94448402.htm
Volkswagen Golf 5-door R 2.0 4Motion DSG 310hk 309000 https://www.blocket.se/vi/94126802.htm