Skip to content

Instantly share code, notes, and snippets.

@aladagemre
Created Dec 30, 2020
Embed
What would you like to do?
N11 kategori listesini çeken bir script
import bs4
import csv
import requests
r = requests.get("https://www.n11.com/site-haritasi")
soup = bs4.BeautifulSoup(r.text, features="html.parser")
with open("kategoriler.csv", "w") as csvfile:
writer = csv.writer(csvfile, delimiter=';', quotechar='"')
mcs = [(a.text, a.get('href')) for a in soup.find_all("a", class_="main-category")]
writer.writerow(["Kategori", "Adres"])
for cat in mcs:
writer.writerow(list(cat))
with open("altkategoriler.csv", "w") as csvfile:
writer = csv.writer(csvfile, delimiter=';', quotechar='"')
mcs = [(div.a.text, div.a.get('href')) for div in soup.find_all("div", class_="sub-category")]
writer.writerow(["Kategori", "Adres"])
for cat in mcs:
writer.writerow(list(cat))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment