Skip to content

Instantly share code, notes, and snippets.

@aladagemre
Created December 30, 2020 23:00
Show Gist options
  • Save aladagemre/da4bdafec53aad01d081056fbe42d604 to your computer and use it in GitHub Desktop.
Save aladagemre/da4bdafec53aad01d081056fbe42d604 to your computer and use it in GitHub Desktop.
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